diff --git a/external-declarations/.gitignore b/external-declarations/.gitignore new file mode 100644 index 0000000000000..9ebf6aba923b5 --- /dev/null +++ b/external-declarations/.gitignore @@ -0,0 +1,5 @@ +/build +/node_modules +/src/*.tsbuildinfo +/tests/actual +/tsc-tests diff --git a/external-declarations/package.json b/external-declarations/package.json new file mode 100644 index 0000000000000..03bb633ab6eb7 --- /dev/null +++ b/external-declarations/package.json @@ -0,0 +1,25 @@ +{ + "name": "external-declarations", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "build": "node ../built/local/tsc.js -p ./src", + "watch": "node ../built/local/tsc.js -w -p ./src", + "run-tests-parallel": "node ./build/test-runner/parallel-run.js --rootPaths=../tests/cases --libPath=../tests/lib --type=all --shardCount=8", + "run-test": "node ./build/test-runner/test-runner-main.js --type=all --rootPaths=c:/dev/TSC/TypeScript/tests/cases ", + "transform-tests-parallel": "node ./build/code-mod/parallel-run.js --rootPaths=../tests/cases --shardCount=8", + "transform-test": "node ./build/code-mod/test-updater.js --rootPaths=../tests/cases", + "run-transformed-tests-parallel": "node ./build/test-runner/parallel-run.js --rootPaths=./tsc-tests/updated-tests --libPath=../tests/lib --type=all --shardCount=8", + "run-transformed-test": "node ./build/test-runner/test-runner-main.js --type=all --rootPaths=c:/dev/TSC/TypeScript/tests/cases " + }, + "author": "", + "license": "ISC", + "dependencies": { + "source-map-support": "^0.5.21", + "typescript": "../" + }, + "devDependencies": { + "@types/node": "^18.11.18" + } +} diff --git a/external-declarations/readme.md b/external-declarations/readme.md new file mode 100644 index 0000000000000..a46e89f38e6a3 --- /dev/null +++ b/external-declarations/readme.md @@ -0,0 +1,18 @@ +# Implementation of declaration emit + +This implementation uses the the parser and printer from the TypeScript code base but replaces the binder and emit resolver with rewritten versions that do not depend on the type checker. + +The declaration transform itself is mostly the same as the version in TypeScript (with some code erased and different imports) + +## Package scripts + +- `build`/ `watch` - Build the code +- `run-tests-parallel` - Emits declarations using tsc and the stand alone emitter for the tests in the TypeScript code base in parallel. Outputs to `tsc-tests` +- `run-test` - Emits declarations using tsc and the stand alone emitter for the tests in the TypeScript code base on a single thread, or filtered if you specify a test name. Outputs to `tsc-tests` +- `transform-tests-parallel` - Transforms the TypeScript tests t add missing type annotations and write them to `tsc-tests\updated-tests`. Runs in parallel +- `transform-test` - Transforms the TypeScript tests t add missing type annotations and write them to `tsc-tests\updated-tests`. Runs on a single thread. Accepts a test name or regex filter +- `run-transformed-tests-parallel` - Same as `run-tests-parallel` but runs on the transformed tests in `tsc-tests\updated-tests` +- `run-transformed-test`- Same as `run-test` but runs on the transformed tests in `tsc-tests\updated-tests` + + +Note: Tests currently just output the declarations, there is no console error message. Use an external diff tool to see differences. \ No newline at end of file diff --git a/external-declarations/src/code-mod/code-transform.ts b/external-declarations/src/code-mod/code-transform.ts new file mode 100644 index 0000000000000..1b804b9285fd0 --- /dev/null +++ b/external-declarations/src/code-mod/code-transform.ts @@ -0,0 +1,276 @@ +import * as ts from "typescript"; +import { NodeBuilderFlags } from "typescript"; +import { map } from "../compiler/lang-utils"; +import { SymbolTracker } from "../compiler/types"; + +const declarationEmitNodeBuilderFlags = + NodeBuilderFlags.MultilineObjectLiterals | + NodeBuilderFlags.WriteClassExpressionAsTypeLiteral | + NodeBuilderFlags.UseTypeOfFunction | + NodeBuilderFlags.UseStructuralFallback | + NodeBuilderFlags.AllowEmptyTuple | + NodeBuilderFlags.GenerateNamesForShadowedTypeParams | + NodeBuilderFlags.NoTruncation; + + +// Define a transformer function +export function addTypeAnnotationTransformer(program: ts.Program, moduleResolutionHost?: ts.ModuleResolutionHost) { + function tryGetReturnType( + typeChecker: ts.TypeChecker, + node: ts.SignatureDeclaration + ): ts.Type | undefined { + const signature = typeChecker.getSignatureFromDeclaration(node); + if (signature) { + return typeChecker.getReturnTypeOfSignature(signature); + } + } + + function isVarConst(node: ts.VariableDeclaration | ts.VariableDeclarationList): boolean { + return !!(ts.getCombinedNodeFlags(node) & ts.NodeFlags.Const); + } + + function isDeclarationReadonly(declaration: ts.Declaration): boolean { + return !!(ts.getCombinedModifierFlags(declaration) & ts.ModifierFlags.Readonly && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + } + + function isLiteralConstDeclaration(node: ts.VariableDeclaration | ts.PropertyDeclaration | ts.PropertySignature | ts.ParameterDeclaration): boolean { + if (isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && isVarConst(node)) { + // TODO: Make sure this is a valid approximation for literal types + return !node.type && 'initializer' in node && !!node.initializer && ts.isLiteralExpression(node.initializer); + // Original TS version + // return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); + } + return false; + } + + const typeChecker = program.getTypeChecker(); + + return (context: ts.TransformationContext) => { + let hasError = false; + let reportError = () => { + hasError = true; + } + const symbolTracker: SymbolTracker | undefined = !moduleResolutionHost? undefined : { + trackSymbol(){ return false; }, + reportInaccessibleThisError: reportError, + reportInaccessibleUniqueSymbolError: reportError, + reportCyclicStructureError: reportError, + reportPrivateInBaseOfClassExpression: reportError, + reportLikelyUnsafeImportRequiredError: reportError, + reportTruncationError: reportError, + moduleResolverHost: moduleResolutionHost as any, + trackReferencedAmbientModule(){}, + trackExternalModuleSymbolOfImportTypeNode(){}, + reportNonlocalAugmentation(){}, + reportNonSerializableProperty(){}, + reportImportTypeNodeResolutionModeOverride() {}, + }; + + function typeToTypeNode(type: ts.Type, enclosingDeclaration: ts.Node) { + const typeNode = typeChecker.typeToTypeNode( + type, + enclosingDeclaration, + declarationEmitNodeBuilderFlags, + // @ts-expect-error Use undocumented parameters + symbolTracker, + ) + if (hasError) { + hasError = false; + return undefined; + } + + return typeNode; + } + // Return a visitor function + return (rootNode: ts.Node) => { + function updateTypesInNodeArray(nodeArray: ts.NodeArray): ts.NodeArray + function updateTypesInNodeArray(nodeArray: ts.NodeArray | undefined): ts.NodeArray | undefined + function updateTypesInNodeArray(nodeArray: ts.NodeArray | undefined) { + if(nodeArray === undefined) return undefined; + return ts.factory.createNodeArray( + nodeArray.map(param => { + return visit(param) as ts.ParameterDeclaration; + }) + ) + } + + // Define a visitor function + function visit(node: ts.Node): ts.Node | ts.Node[] { + if(ts.isParameter(node) && !node.type) { + const type = typeChecker.getTypeAtLocation(node); + if(type) { + const typeNode = typeToTypeNode(type, node); + return ts.factory.updateParameterDeclaration( + node, + node.modifiers, + node.dotDotDotToken, + node.name, + node.questionToken, + typeNode, + node.initializer + ) + } + } + // Check if node is a variable declaration + if (ts.isVariableDeclaration(node) && !node.type && !isLiteralConstDeclaration(node)) { + const type = typeChecker.getTypeAtLocation(node); + const typeNode = typeToTypeNode(type, node) + return ts.factory.updateVariableDeclaration( + node, + node.name, + undefined, + typeNode, + node.initializer + ); + } + + if (ts.isFunctionDeclaration(node) && !node.type) { + const type = tryGetReturnType(typeChecker, node); + if(type) { + + const typeNode = typeToTypeNode(type, node); + return ts.factory.updateFunctionDeclaration( + node, + node.modifiers, + node.asteriskToken, + node.name, + updateTypesInNodeArray(node.typeParameters), + updateTypesInNodeArray(node.parameters), + typeNode, + node.body + ) + } + } + if(ts.isPropertySignature(node) && !node.type && !isLiteralConstDeclaration(node)) { + const type = typeChecker.getTypeAtLocation(node); + const typeNode = typeToTypeNode(type, node); + return ts.factory.updatePropertySignature( + node, + node.modifiers, + node.name, + node.questionToken, + typeNode, + ); + } + if(ts.isPropertyDeclaration(node) && !node.type && !isLiteralConstDeclaration(node)) { + const type = typeChecker.getTypeAtLocation(node); + const typeNode = typeToTypeNode(type, node); + return ts.factory.updatePropertyDeclaration( + node, + node.modifiers, + node.name, + node.questionToken ?? node.exclamationToken, + typeNode, + node.initializer + ); + } + if(ts.isMethodSignature(node) && !node.type) { + const type = tryGetReturnType(typeChecker, node); + if(type) { + + const typeNode = typeToTypeNode(type, node); + return ts.factory.updateMethodSignature( + node, + node.modifiers, + node.name, + node.questionToken, + updateTypesInNodeArray(node.typeParameters), + updateTypesInNodeArray(node.parameters), + typeNode, + ); + } + } + if(ts.isCallSignatureDeclaration(node)) { + const type = tryGetReturnType(typeChecker, node); + if(type) { + const typeNode = typeToTypeNode(type, node); + return ts.factory.updateCallSignature( + node, + updateTypesInNodeArray(node.typeParameters), + updateTypesInNodeArray(node.parameters), + typeNode, + ) + } + } + if(ts.isMethodDeclaration(node) && !node.type) { + const type = tryGetReturnType(typeChecker, node); + if(type) { + + const typeNode = typeToTypeNode(type, node); + return ts.factory.updateMethodDeclaration( + node, + node.modifiers, + node.asteriskToken, + node.name, + node.questionToken, + updateTypesInNodeArray(node.typeParameters), + updateTypesInNodeArray(node.parameters), + typeNode, + node.body, + ); + } + } + if(ts.isGetAccessorDeclaration(node) && !node.type) { + const type = tryGetReturnType(typeChecker, node); + if(type) { + const typeNode = typeToTypeNode(type, node); + return ts.factory.updateGetAccessorDeclaration( + node, + node.modifiers, + node.name, + updateTypesInNodeArray(node.parameters), + typeNode, + node.body, + ); + } + } + if(ts.isSetAccessorDeclaration(node) && !node.parameters[0]?.type) { + return ts.factory.updateSetAccessorDeclaration( + node, + node.modifiers, + node.name, + updateTypesInNodeArray(node.parameters), + node.body, + ); + } + if ( ts.isConstructorDeclaration(node)) { + return ts.factory.updateConstructorDeclaration( + node, + node.modifiers, + updateTypesInNodeArray(node.parameters), + node.body, + ) + } + if(ts.isConstructSignatureDeclaration(node)) { + const type = tryGetReturnType(typeChecker, node); + if(type) { + const typeNode = typeToTypeNode(type, node); + return ts.factory.updateConstructSignature( + node, + updateTypesInNodeArray(node.typeParameters), + updateTypesInNodeArray(node.parameters), + typeNode, + ) + } + } + if(ts.isExportAssignment(node) && node.expression.kind !== ts.SyntaxKind.Identifier) { + const type = typeChecker.getTypeAtLocation(node.expression); + if(type) { + const typeNode = typeToTypeNode(type, node); + const newId = ts.factory.createIdentifier("_default"); + const varDecl = ts.factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, typeNode, /*initializer*/ undefined); + const statement = ts.factory.createVariableStatement( + [], + ts.factory.createVariableDeclarationList([varDecl], ts.NodeFlags.Const) + ); + return [statement, ts.factory.updateExportAssignment(node, node.modifiers, newId)]; + } + } + // Otherwise, visit each child node recursively + return ts.visitEachChild(node, visit, context); + } + // Start visiting from root node + return ts.visitNode(rootNode, visit)!; + }; + }; +} \ No newline at end of file diff --git a/external-declarations/src/code-mod/index.ts b/external-declarations/src/code-mod/index.ts new file mode 100644 index 0000000000000..b0cdfec800b0a --- /dev/null +++ b/external-declarations/src/code-mod/index.ts @@ -0,0 +1,35 @@ +// Import TypeScript module +import * as ts from "typescript"; +import { isDeclarationFileName } from "../compiler/utils"; +import { addTypeAnnotationTransformer } from "./code-transform"; + +(ts as any).Debug .enableDebugInfo(); + +// Read tsconfig.json file from disk +const tsconfig = ts.readConfigFile("tsconfig.json", ts.sys.readFile); + +// Parse JSON content to get compiler options and file names +const parsed = ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, "./"); +const options = parsed.options; +// Pass compiler options and file names to createProgram +const program = ts.createProgram(parsed.fileNames, options); + +program.getSemanticDiagnostics(); +const files = program.getSourceFiles(); +for (const file of files) { + if (isDeclarationFileName(file.fileName)) continue; + + const transformedFile = ts.transform(file, [ + addTypeAnnotationTransformer(program), + ]); + + const printer = ts.createPrinter({ + onlyPrintJsDocStyle: true, + newLine: options.newLine, + target: options.target, + } as ts.PrinterOptions); + const resultStr = printer.printFile( + transformedFile.transformed[0] as ts.SourceFile + ); + console.log(resultStr); +} diff --git a/external-declarations/src/code-mod/parallel-run.ts b/external-declarations/src/code-mod/parallel-run.ts new file mode 100644 index 0000000000000..9cf7dec5391ce --- /dev/null +++ b/external-declarations/src/code-mod/parallel-run.ts @@ -0,0 +1,88 @@ +import * as fs from 'fs' +import * as path from 'path' +import * as childProcess from "child_process"; +import { ArgType, parseArgs } from '../utils/cli-parser'; + +type ExecuteResult = { + error: childProcess.ExecException | null + stdout: string, + stderr: string, +} + +function exec(cmd: string, dir: string, onStdOut: (s: string) => void) { + return new Promise((resolve) => { + console.log(`In ${dir} Executing: ${cmd}`); + + const ls = childProcess.spawn(cmd, [], { + cwd: path.resolve(path.join(process.cwd(), dir)), + shell: true + }); + let stdout = "" + let stderr = "" + ls.stdout.on('data', function (data) { + if(!onStdOut) { + process.stdout.write(data.toString()); + } else { + onStdOut(data.toString()); + } + stdout += data.toString(); + }); + + ls.stderr.on('data', function (data) { + process.stderr.write(data.toString()); + stderr += data.toString(); + }); + + ls.on('error', function(err) { + console.log(err); + }) + ls.on('exit', function (code) { + console.log('exited:' + code?.toString()); + resolve({ + error: !code ? null : Object.assign(new Error(""), { + code, + cmd: cmd, + }), + stderr, + stdout + }) + }); + }) +} + +const { value: parsedArgs, printUsageOnErrors } = parseArgs(process.argv.slice(2), { + default: { + type: ArgType.String(), + description: "Test filter to run", + }, + rootPaths: ArgType.StringArray(), + shardCount: ArgType.Number(), +}); +printUsageOnErrors(); + +const shardCount = parsedArgs.shardCount ?? 6; + +async function main() { + let runCount = 0; + const commandLine = `node ./build/code-mod/test-updater.js ${process.argv.slice(2).join(" ")} ${ + parsedArgs.shardCount === undefined ? `--shardCount=${shardCount} `: "" + }`; + let lastWrite = new Date().getTime(); + const startTime = new Date().getTime(); + const elapsedTime = (now: number) => `${((now - startTime) / 1000 / 60).toFixed(2)} minutes` + const promisees = Array.from({ length: shardCount}).map(async (_, index) => { + await exec(commandLine + ` --shard=${index}`, "./", out => { + runCount += (out.match(/Ran:/g) || []).length; + if(new Date().getTime() - lastWrite > 2000) { + lastWrite = new Date().getTime() + console.log(`Run count: ${runCount} after ${elapsedTime(lastWrite)}`); + } + }); + console.log(`Shard ${index} completed`); + }); + await Promise.all(promisees); + const endTime = new Date().getTime(); + console.log(`Took ${elapsedTime(endTime)} to complete ${runCount}`) +} + +main(); \ No newline at end of file diff --git a/external-declarations/src/code-mod/test-updater.ts b/external-declarations/src/code-mod/test-updater.ts new file mode 100644 index 0000000000000..0087525ddd44c --- /dev/null +++ b/external-declarations/src/code-mod/test-updater.ts @@ -0,0 +1,141 @@ +import 'source-map-support/register'; +import * as fsPath from 'path' +import * as fs from 'fs/promises' +import { parserConfiguration, ArgType, parseArgs } from "../utils/cli-parser"; +import { isDeclarationFile, isJavaScriptFile, isJSONFile, isSourceMapFile, normalizePath } from '../compiler/path-utils'; +import { isRelevantTestFile, loadTestCase } from '../test-runner/utils'; +import ts = require('typescript'); +import { compileFiles, setCompilerOptionsFromHarnessSetting, TestFile } from '../test-runner/tsc-infrastructure/compiler-run'; +import { splitContentByNewlines, TestCaseContent, TestUnitData } from '../test-runner/tsc-infrastructure/test-file-parser'; +import { addTypeAnnotationTransformer } from './code-transform'; +import { ensureDir, readAllFiles } from '../utils/fs-utils'; + +(ts as any).Debug .enableDebugInfo(); + +export const testRunnerCLIConfiguration = parserConfiguration({ + default: { + type: ArgType.String(), + description: "Test filter to run", + }, + rootPaths: ArgType.StringArray(), + shard: ArgType.Number(), + shardCount: ArgType.Number(), +}) + +const excludeFilter =/\/fourslash\//; +const { value: parsedArgs, printUsageOnErrors } = parseArgs(process.argv.slice(2), testRunnerCLIConfiguration); +printUsageOnErrors(); + +const rootCasePaths = parsedArgs.rootPaths ?? [ './tests/sources' ] +const filter = parsedArgs.default ? new RegExp(parsedArgs.default) : /.*\.ts/ + +const shard = parsedArgs.shard +const shardCount = parsedArgs.shardCount + +const allTests = rootCasePaths + .flatMap(r => readAllFiles(r, filter).map((file) => ({ file, root: r}))) + .filter(f => !excludeFilter.exec(f.file));; + + + +async function writeTestCase(testData: TestCaseContent & { BOM: string }, path: string) { + let lines = splitContentByNewlines(testData.code); + let result: string[] = []; + let copyFrom = 0; + function pushFrom(target: string[], source: string[], from: number = 0, to: number = source.length) { + for(let i = from; i< to; i++) { + target.push(source[i]); + } + } + for (const file of testData.testUnitData) { + if(file.content === undefined) continue; + + pushFrom(result, lines, copyFrom, file.startLine) + + pushFrom(result, splitContentByNewlines(file.content)); + + copyFrom = file.endLine + 1; + } + pushFrom(result, lines, copyFrom, lines.length) + await ensureDir(fsPath.dirname(path)); + const content = testData.BOM + result.join(lines.delimiter); + await fs.writeFile(path, content); +} + +async function main() { + const testsPerShared = shardCount && Math.round(allTests.length / shardCount); + const [start, end] = shard == undefined || shardCount == undefined || testsPerShared == undefined ? + [0, allTests.length] : + [shard * testsPerShared, (shard == shardCount - 1) ? allTests.length : (shard + 1) * testsPerShared]; + + + for (let count = start; count < end; count++) { + const testFile = normalizePath(allTests[count].file); + const rootPath = normalizePath(allTests[count].root); + const caseData = await loadTestCase(testFile); + + const settings: ts.CompilerOptions = {}; + setCompilerOptionsFromHarnessSetting(caseData.settings, settings); + + function createHarnessTestFile(lastUnit: TestUnitData): TestFile { + return { unitName: lastUnit.name, content: lastUnit.content, fileOptions: lastUnit.fileOptions }; + } + + const toBeCompiled = caseData.testUnitData.map(unit => { + return createHarnessTestFile(unit); + }); + + await writeTestCase(caseData, testFile.replace(rootPath, "./tsc-tests/original-tests")) + + const result = compileFiles(toBeCompiled, [], { + declaration: "true", + isolatedDeclarations: "true", + removeComments: "false", + }, settings, undefined); + const program = result.program!; + + + + for(const testFileContent of caseData.testUnitData) { + if(!isRelevantTestFile(testFileContent)) continue; + try { + const sourceFile = program.getSourceFile(testFileContent.name)!; + program.getDeclarationDiagnostics(sourceFile) + + if(!sourceFile) continue; + let moduleResolutionHost: ts.ModuleResolutionHost| undefined = undefined; + program.emit(sourceFile, undefined, undefined, true, { + afterDeclarations:[ + (c) => { + // @ts-expect-error getEmitHost is not exposed + moduleResolutionHost = c.getEmitHost(); + return (v) => v; + }] + }) + const transformedFile = ts.transform(sourceFile, [ + addTypeAnnotationTransformer(program, moduleResolutionHost), + ]); + + const printer = ts.createPrinter({ + onlyPrintJsDocStyle: true, + newLine: settings.newLine, + target: settings.target, + removeComments: false, + } as ts.PrinterOptions); + + + const resultStr = printer.printFile( + transformedFile.transformed[0] as ts.SourceFile + ); + testFileContent.content = resultStr; + }catch(e) { + console.log(`Test ${testFile} failed to transform`) + process.exit(); + } + } + await writeTestCase(caseData, testFile.replace(rootPath, "./tsc-tests/updated-tests")) + console.log(`Ran: ${count}`); + } +} + +main(); \ No newline at end of file diff --git a/external-declarations/src/compiler/debug.ts b/external-declarations/src/compiler/debug.ts new file mode 100644 index 0000000000000..551ea118d26d0 --- /dev/null +++ b/external-declarations/src/compiler/debug.ts @@ -0,0 +1,319 @@ +import { Symbol, Node, NodeArray, SyntaxKind, unescapeLeadingUnderscores, SortedReadonlyArray, NodeFlags, ModifierFlags, EmitFlags, SymbolFlags, TypeFlags, ObjectFlags, FlowFlags, FlowNodeBase, Type, symbolName, LiteralType, BigIntLiteralType, ObjectType, Signature, isIdentifier, idText, isPrivateIdentifier, isStringLiteral, isNumericLiteral, isBigIntLiteral, isTypeParameterDeclaration, isParameter, isConstructorDeclaration, isGetAccessorDeclaration, isSetAccessorDeclaration, isCallSignatureDeclaration, isConstructSignatureDeclaration, isIndexSignatureDeclaration, isTypePredicateNode, isTypeReferenceNode, isFunctionTypeNode, isConstructorTypeNode, isTypeQueryNode, isTypeLiteralNode, isArrayTypeNode, isTupleTypeNode, isOptionalTypeNode, isRestTypeNode, isUnionTypeNode, isIntersectionTypeNode, isConditionalTypeNode, isInferTypeNode, isParenthesizedTypeNode, isThisTypeNode, isTypeOperatorNode, isIndexedAccessTypeNode, isMappedTypeNode, isLiteralTypeNode, isNamedTupleMember, isImportTypeNode, isParseTreeNode, getParseTreeNode, FlowNode, FlowSwitchClause, FlowLabel, MapLike } from "typescript"; +import * as ts from "typescript"; +import { getSourceFileOfNode, getSourceTextOfNodeFromSourceFile} from "./utils"; +import { every, map, stableSort, compareValues } from "./lang-utils"; + +/** @internal */ +export const enum AssertionLevel { + None = 0, + Normal = 1, + Aggressive = 2, + VeryAggressive = 3, +} +type AssertionKeys = keyof typeof Debug; + +const hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Indicates whether a map-like contains an own property with the specified key. + * + * @param map A map-like. + * @param key A property key. + * + * @internal + */ +export function hasProperty(map: MapLike, key: string): boolean { + return hasOwnProperty.call(map, key); +} + + + + +/** + * Tests whether an assertion function should be executed. If it shouldn't, it is cached and replaced with `ts.noop`. + * Replaced assertion functions are restored when `Debug.setAssertionLevel` is set to a high enough level. + * @param level The minimum assertion level required. + * @param name The name of the current assertion function. + */ +function shouldAssertFunction(_level: AssertionLevel, _name: K): boolean { + return true; +} + +type AnyFunction = (...a: any) => any; +/** @internal */ +export namespace Debug { + + + export function fail(message?: string, stackCrawlMark?: AnyFunction): never { + debugger; + const e = new Error(message ? `Debug Failure. ${message}` : "Debug Failure."); + if ((Error as any).captureStackTrace) { + (Error as any).captureStackTrace(e, stackCrawlMark || fail); + } + throw e; + } + + export function failBadSyntaxKind(node: Node, message?: string, stackCrawlMark?: AnyFunction): never { + return fail( + `${message || "Unexpected node."}\r\nNode ${formatSyntaxKind(node.kind)} was unexpected.`, + stackCrawlMark || failBadSyntaxKind); + } + + export function assert(expression: unknown, message?: string, verboseDebugInfo?: string | (() => string), stackCrawlMark?: AnyFunction): asserts expression { + if (!expression) { + message = message ? `False expression: ${message}` : "False expression."; + if (verboseDebugInfo) { + message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); + } + fail(message, stackCrawlMark || assert); + } + } + + export function assertEqual(a: T, b: T, msg?: string, msg2?: string, stackCrawlMark?: AnyFunction): void { + if (a !== b) { + const message = msg ? msg2 ? `${msg} ${msg2}` : msg : ""; + fail(`Expected ${a} === ${b}. ${message}`, stackCrawlMark || assertEqual); + } + } + + export function assertLessThan(a: number, b: number, msg?: string, stackCrawlMark?: AnyFunction): void { + if (a >= b) { + fail(`Expected ${a} < ${b}. ${msg || ""}`, stackCrawlMark || assertLessThan); + } + } + + export function assertLessThanOrEqual(a: number, b: number, stackCrawlMark?: AnyFunction): void { + if (a > b) { + fail(`Expected ${a} <= ${b}`, stackCrawlMark || assertLessThanOrEqual); + } + } + + export function assertGreaterThanOrEqual(a: number, b: number, stackCrawlMark?: AnyFunction): void { + if (a < b) { + fail(`Expected ${a} >= ${b}`, stackCrawlMark || assertGreaterThanOrEqual); + } + } + + export function assertIsDefined(value: T, message?: string, stackCrawlMark?: AnyFunction): asserts value is NonNullable { + // eslint-disable-next-line no-null/no-null + if (value === undefined || value === null) { + fail(message, stackCrawlMark || assertIsDefined); + } + } + + export function checkDefined(value: T | null | undefined, message?: string, stackCrawlMark?: AnyFunction): T { + assertIsDefined(value, message, stackCrawlMark || checkDefined); + return value; + } + + export function assertEachIsDefined(value: NodeArray, message?: string, stackCrawlMark?: AnyFunction): asserts value is NodeArray; + export function assertEachIsDefined(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction): asserts value is readonly NonNullable[]; + export function assertEachIsDefined(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction) { + for (const v of value) { + assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined); + } + } + + export function checkEachDefined(value: A, message?: string, stackCrawlMark?: AnyFunction): A { + assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined); + return value; + } + + export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never { + const detail = typeof member === "object" && hasProperty(member, "kind") && hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind((member as Node).kind) : JSON.stringify(member); + return fail(`${message} ${detail}`, stackCrawlMark || assertNever); + } + + export function assertEachNode(nodes: NodeArray, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray; + export function assertEachNode(nodes: readonly T[], test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[]; + export function assertEachNode(nodes: NodeArray | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray | undefined; + export function assertEachNode(nodes: readonly T[] | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[] | undefined; + export function assertEachNode(nodes: readonly Node[], test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction): void; + export function assertEachNode(nodes: readonly Node[] | undefined, test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssertFunction(AssertionLevel.Normal, "assertEachNode")) { + assert( + test === undefined || every(nodes, test), + message || "Unexpected node.", + () => `Node array did not pass test '${getFunctionName(test)}'.`, + stackCrawlMark || assertEachNode); + } + } + + export function assertNode(node: T | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U; + export function assertNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; + export function assertNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssertFunction(AssertionLevel.Normal, "assertNode")) { + assert( + node !== undefined && (test === undefined || test(node)), + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node?.kind)} did not pass test '${getFunctionName(test!)}'.`, + stackCrawlMark || assertNode); + } + } + + export function assertNotNode(node: T | undefined, test: (node: Node) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is Exclude; + export function assertNotNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; + export function assertNotNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssertFunction(AssertionLevel.Normal, "assertNotNode")) { + assert( + node === undefined || test === undefined || !test(node), + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node!.kind)} should not have passed test '${getFunctionName(test!)}'.`, + stackCrawlMark || assertNotNode); + } + } + + export function assertOptionalNode(node: T, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U; + export function assertOptionalNode(node: T | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U | undefined; + export function assertOptionalNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; + export function assertOptionalNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssertFunction(AssertionLevel.Normal, "assertOptionalNode")) { + assert( + test === undefined || node === undefined || test(node), + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node?.kind)} did not pass test '${getFunctionName(test!)}'.`, + stackCrawlMark || assertOptionalNode); + } + } + + export function assertOptionalToken(node: T, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract; + export function assertOptionalToken(node: T | undefined, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract | undefined; + export function assertOptionalToken(node: Node | undefined, kind: SyntaxKind | undefined, message?: string, stackCrawlMark?: AnyFunction): void; + export function assertOptionalToken(node: Node | undefined, kind: SyntaxKind | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssertFunction(AssertionLevel.Normal, "assertOptionalToken")) { + assert( + kind === undefined || node === undefined || node.kind === kind, + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node?.kind)} was not a '${formatSyntaxKind(kind)}' token.`, + stackCrawlMark || assertOptionalToken); + } + } + + export function assertMissingNode(node: Node | undefined, message?: string, stackCrawlMark?: AnyFunction): asserts node is undefined; + export function assertMissingNode(node: Node | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssertFunction(AssertionLevel.Normal, "assertMissingNode")) { + assert( + node === undefined, + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node!.kind)} was unexpected'.`, + stackCrawlMark || assertMissingNode); + } + } + + /** + * Asserts a value has the specified type in typespace only (does not perform a runtime assertion). + * This is useful in cases where we switch on `node.kind` and can be reasonably sure the type is accurate, and + * as a result can reduce the number of unnecessary casts. + */ + export function type(value: unknown): asserts value is T; + export function type(_value: unknown) { } + + export function getFunctionName(func: AnyFunction) { + if (typeof func !== "function") { + return ""; + } + else if (hasProperty(func, "name")) { + return (func as any).name; + } + else { + const text = Function.prototype.toString.call(func); + const match = /^function\s+([\w\$]+)\s*\(/.exec(text); + return match ? match[1] : ""; + } + } + + export function formatSymbol(symbol: Symbol): string { + return `{ name: ${unescapeLeadingUnderscores(symbol.escapedName)}; flags: ${formatSymbolFlags(symbol.flags)}; declarations: ${map(symbol.declarations, node => formatSyntaxKind(node.kind))} }`; + } + + /** + * Formats an enum value as a string for debugging and debug assertions. + */ + export function formatEnum(value = 0, enumObject: any, isFlags?: boolean) { + const members = getEnumMembers(enumObject); + if (value === 0) { + return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0"; + } + if (isFlags) { + const result: string[] = []; + let remainingFlags = value; + for (const [enumValue, enumName] of members) { + if (enumValue > value) { + break; + } + if (enumValue !== 0 && enumValue & value) { + result.push(enumName); + remainingFlags &= ~enumValue; + } + } + if (remainingFlags === 0) { + return result.join("|"); + } + } + else { + for (const [enumValue, enumName] of members) { + if (enumValue === value) { + return enumName; + } + } + } + return value.toString(); + } + + const enumMemberCache = new Map>(); + + function getEnumMembers(enumObject: any) { + // Assuming enum objects do not change at runtime, we can cache the enum members list + // to reuse later. This saves us from reconstructing this each and every time we call + // a formatting function (which can be expensive for large enums like SyntaxKind). + const existing = enumMemberCache.get(enumObject); + if (existing) { + return existing; + } + + const result: [number, string][] = []; + for (const name in enumObject) { + const value = enumObject[name]; + if (typeof value === "number") { + result.push([value, name]); + } + } + + const sorted = stableSort<[number, string]>(result, (x, y) => compareValues(x[0], y[0])); + enumMemberCache.set(enumObject, sorted); + return sorted; + } + + export function formatSyntaxKind(kind: SyntaxKind | undefined): string { + return formatEnum(kind, (ts as any).SyntaxKind, /*isFlags*/ false); + } + + + export function formatNodeFlags(flags: NodeFlags | undefined): string { + return formatEnum(flags, (ts as any).NodeFlags, /*isFlags*/ true); + } + + export function formatModifierFlags(flags: ModifierFlags | undefined): string { + return formatEnum(flags, (ts as any).ModifierFlags, /*isFlags*/ true); + } + + export function formatEmitFlags(flags: EmitFlags | undefined): string { + return formatEnum(flags, (ts as any).EmitFlags, /*isFlags*/ true); + } + + export function formatSymbolFlags(flags: SymbolFlags | undefined): string { + return formatEnum(flags, (ts as any).SymbolFlags, /*isFlags*/ true); + } + + export function formatTypeFlags(flags: TypeFlags | undefined): string { + return formatEnum(flags, (ts as any).TypeFlags, /*isFlags*/ true); + } + + export function formatObjectFlags(flags: ObjectFlags | undefined): string { + return formatEnum(flags, (ts as any).ObjectFlags, /*isFlags*/ true); + } + + export function formatFlowFlags(flags: FlowFlags | undefined): string { + return formatEnum(flags, (ts as any).FlowFlags, /*isFlags*/ true); + } +} diff --git a/external-declarations/src/compiler/declaration-emit.ts b/external-declarations/src/compiler/declaration-emit.ts new file mode 100644 index 0000000000000..4d1dc97f9b8f9 --- /dev/null +++ b/external-declarations/src/compiler/declaration-emit.ts @@ -0,0 +1,1723 @@ +import { Symbol, SourceFile, DiagnosticWithLocation, factory, CommentRange, Node, getParseTreeNode, SyntaxKind, SignatureDeclaration, ParameterDeclaration, getTrailingCommentRanges, getLeadingCommentRanges, NodeBuilderFlags, VisitResult, ExportAssignment, DeclarationName, Declaration, ModuleDeclaration, SymbolFlags, getNameOfDeclaration, isExportAssignment, Bundle, visitNodes, setTextRange, createUnparsedSourceFile, FileReference, NodeArray, Statement, isExternalModule, isImportEqualsDeclaration, isExternalModuleReference, isStringLiteralLike, isImportDeclaration, isStringLiteral, UnparsedSource, isUnparsedSource, BindingName, ArrayBindingElement, isIdentifier, ModifierFlags, TypeNode, FunctionDeclaration, MethodDeclaration, GetAccessorDeclaration, SetAccessorDeclaration, BindingElement, ConstructSignatureDeclaration, VariableDeclaration, MethodSignature, CallSignatureDeclaration, PropertyDeclaration, PropertySignature, visitNode, isPropertySignature, NamedDeclaration, isFunctionDeclaration, OmittedExpression, isOmittedExpression, AccessorDeclaration, isSetAccessorDeclaration, TypeParameterDeclaration, isSourceFile, isTypeAliasDeclaration, isModuleDeclaration, isClassDeclaration, isInterfaceDeclaration, isFunctionLike, isIndexSignatureDeclaration, isMappedTypeNode, EntityNameOrEntityNameExpression, setCommentRange, getCommentRange, ImportEqualsDeclaration, ImportDeclaration, ExportDeclaration, ImportTypeNode, StringLiteral, AssertClause, isSemicolonClassElement, isMethodDeclaration, isMethodSignature, isTypeQueryNode, isEntityName, visitEachChild, isPrivateIdentifier, isTypeNode, isTupleTypeNode, getLineAndCharacterOfPosition, setEmitFlags, EmitFlags, setOriginalNode, GeneratedIdentifierFlags, NodeFlags, canHaveModifiers, isTypeParameterDeclaration, NamespaceDeclaration, Identifier, VariableStatement, isPropertyAccessExpression, unescapeLeadingUnderscores, ModuleBody, BindingPattern, isExportDeclaration, HasModifiers, Modifier, isModifier, HeritageClause, InterfaceDeclaration, ClassDeclaration, TypeAliasDeclaration, EnumDeclaration, ConstructorDeclaration, IndexSignatureDeclaration, ExpressionWithTypeArguments, TypeReferenceNode, ConditionalTypeNode, FunctionTypeNode, ConstructorTypeNode, isStatement, isArrayBindingElement, isBindingElement, isClassElement, isExpressionWithTypeArguments, isLiteralExpression, isTypeElement, isVariableDeclaration, NodeFactory } from "typescript"; +import { Debug } from "./debug"; +import { Diagnostics } from "./diagnosticInformationMap.generated"; +import { filter, stringContains, concatenate, last, forEach, length, pushIfUnique, map, mapDefined, arrayFrom, contains, startsWith, some, append, emptyArray, isArray, compact, flatMap, flatten, orderedRemoveItem, tryCast } from "./lang-utils"; +import { getDirectoryPath, normalizeSlashes, toFileNameLowerCase } from "./path-utils"; +import { transformNodes } from "./transformer"; +import { EmitHost, EmitResolver, GetSymbolAccessibilityDiagnostic, LateBoundDeclaration, NodeId, ResolutionMode, SymbolAccessibility, SymbolAccessibilityResult, SymbolTracker, TransformationContext } from "./types"; +import { getEffectiveModifierFlags, skipTrivia, getLeadingCommentRangesOfNode, LateVisibilityPaintedStatement, AnyImportSyntax, getSourceFileOfNode, createDiagnosticForNode, getTextOfNode, declarationNameToString, canProduceDiagnostics, getThisParameter, isDeclaration, DeclarationDiagnosticProducing, setParent, getFirstConstructorWithBody, hasSyntacticModifier, visitArray, AllAccessorDeclarations, isNightly, createGetSymbolAccessibilityDiagnosticForNode, getOriginalNodeId, addRelatedInfo, isExternalOrCommonJsModule, isJsonSourceFile, isSourceFileJS, getResolvedExternalModuleName, isSourceFileNotJson, isAnyImportSyntax, createEmptyExports, isExternalModuleAugmentation, isGlobalScopeAugmentation, isLateVisibilityPaintedStatement, hasDynamicName, hasEffectiveModifier, isBindingPattern, isLiteralImportTypeNode, removeAllComments, needsScopeMarker, hasJSDocNodes, isExternalModuleIndicator, getOutputPathsFor, getSetAccessorValueParameter, getExternalModuleNameFromDeclaration, getExternalModuleImportEqualsDeclarationExpression, getResolutionModeOverrideForClause, isEntityNameExpression, getEffectiveBaseTypeNode, createGetSymbolAccessibilityDiagnosticForNodeName, pathContainsNodeModules, hasIdentifierComputedName, isIdentifierANonContextualKeyword, } from "./utils"; + +/** @internal */ +export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, file: SourceFile | undefined): DiagnosticWithLocation[] | undefined { + const compilerOptions = host.getCompilerOptions(); + const result = transformNodes(resolver, host, factory, compilerOptions, file ? [file] : filter(host.getSourceFiles(), isSourceFileNotJson), [transformDeclarations], /*allowDtsFiles*/ false); + return result.diagnostics; +} + +function hasInternalAnnotation(range: CommentRange, currentSourceFile: SourceFile) { + const comment = currentSourceFile.text.substring(range.pos, range.end); + return stringContains(comment, "@internal"); +} + +/** @internal */ +export function isInternalDeclaration(node: Node, currentSourceFile: SourceFile) { + const parseTreeNode = getParseTreeNode(node); + if (parseTreeNode && parseTreeNode.kind === SyntaxKind.Parameter) { + const paramIdx = (parseTreeNode.parent as SignatureDeclaration).parameters.indexOf(parseTreeNode as ParameterDeclaration); + const previousSibling = paramIdx > 0 ? (parseTreeNode.parent as SignatureDeclaration).parameters[paramIdx - 1] : undefined; + const text = currentSourceFile.text; + const commentRanges = previousSibling + ? concatenate( + // to handle + // ... parameters, /** @internal */ + // public param: string + getTrailingCommentRanges(text, skipTrivia(text, previousSibling.end + 1, /* stopAfterLineBreak */ false, /* stopAtComments */ true)), + getLeadingCommentRanges(text, node.pos) + ) + : getTrailingCommentRanges(text, skipTrivia(text, node.pos, /* stopAfterLineBreak */ false, /* stopAtComments */ true)); + return commentRanges && commentRanges.length && hasInternalAnnotation(last(commentRanges), currentSourceFile); + } + const leadingCommentRanges = parseTreeNode && getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile); + return !!forEach(leadingCommentRanges, range => { + return hasInternalAnnotation(range, currentSourceFile); + }); +} + +const declarationEmitNodeBuilderFlags = + NodeBuilderFlags.MultilineObjectLiterals | + NodeBuilderFlags.WriteClassExpressionAsTypeLiteral | + NodeBuilderFlags.UseTypeOfFunction | + NodeBuilderFlags.UseStructuralFallback | + NodeBuilderFlags.AllowEmptyTuple | + NodeBuilderFlags.GenerateNamesForShadowedTypeParams | + NodeBuilderFlags.NoTruncation; + +/** + * Transforms a ts file into a .d.ts file + * This process requires type information, which is retrieved through the emit resolver. Because of this, + * in many places this transformer assumes it will be operating on parse tree nodes directly. + * This means that _no transforms should be allowed to occur before this one_. + * + * @internal + */ +export function transformDeclarations(context: TransformationContext) { + const throwDiagnostic = () => Debug.fail("Diagnostic emitted without context"); + let getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic = throwDiagnostic; + let needsDeclare = true; + let isBundledEmit = false; + let resultHasExternalModuleIndicator = false; + let needsScopeFixMarker = false; + let resultHasScopeMarker = false; + let enclosingDeclaration: Node; + let necessaryTypeReferences: Set<[specifier: string, mode: ResolutionMode]> | undefined; + let lateMarkedStatements: LateVisibilityPaintedStatement[] | undefined; + let lateStatementReplacementMap: Map>; + let suppressNewDiagnosticContexts: boolean; + let exportedModulesFromDeclarationEmit: Symbol[] | undefined; + + const { factory } = context; + const host = context.getEmitHost(); + const symbolTracker: SymbolTracker = { + trackSymbol, + reportInaccessibleThisError, + reportInaccessibleUniqueSymbolError, + reportCyclicStructureError, + reportPrivateInBaseOfClassExpression, + reportLikelyUnsafeImportRequiredError, + reportTruncationError, + moduleResolverHost: host, + trackReferencedAmbientModule, + trackExternalModuleSymbolOfImportTypeNode, + reportNonlocalAugmentation, + reportNonSerializableProperty, + reportImportTypeNodeResolutionModeOverride, + }; + let errorNameNode: DeclarationName | undefined; + let errorFallbackNode: Declaration | undefined; + + let currentSourceFile: SourceFile; + let refs: Map; + let libs: Map; + let emittedImports: readonly AnyImportSyntax[] | undefined; // must be declared in container so it can be `undefined` while transformer's first pass + const resolver = context.getEmitResolver(); + const options = context.getCompilerOptions(); + const { noResolve, stripInternal } = options; + const isolatedDeclarations = true; + return transformRoot; + + function reportIsolatedDeclarationError(node: Node) { + context.addDiagnostic(createDiagnosticForNode( + node, + Diagnostics.Declaration_emit_for_this_file_requires_type_resolution_An_explicit_type_annotation_may_unblock_declaration_emit + )); + } + function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives: readonly [specifier: string, mode: ResolutionMode][] | undefined): void { + if (!typeReferenceDirectives) { + return; + } + necessaryTypeReferences = necessaryTypeReferences || new Set(); + for (const ref of typeReferenceDirectives) { + necessaryTypeReferences.add(ref); + } + } + + function trackReferencedAmbientModule(node: ModuleDeclaration, symbol: Symbol) { + // If it is visible via `// `, then we should just use that + // TODO: isolatedDeclarations: see about .All flag + const directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, (SymbolFlags as any).All); + if (length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference + const container = getSourceFileOfNode(node); + refs.set(getOriginalNodeId(container), container); + } + + function handleSymbolAccessibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) { + if (symbolAccessibilityResult.accessibility === SymbolAccessibility.Accessible) { + // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info + if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { + if (!lateMarkedStatements) { + lateMarkedStatements = symbolAccessibilityResult.aliasesToMakeVisible; + } + else { + for (const ref of symbolAccessibilityResult.aliasesToMakeVisible) { + pushIfUnique(lateMarkedStatements, ref); + } + } + } + + // TODO: Do all these accessibility checks inside/after the first pass in the checker when declarations are enabled, if possible + } + else { + // Report error + const errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult); + if (errorInfo) { + if (errorInfo.typeName) { + context.addDiagnostic(createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, + errorInfo.diagnosticMessage, + getTextOfNode(errorInfo.typeName), + symbolAccessibilityResult.errorSymbolName, + symbolAccessibilityResult.errorModuleName)); + } + else { + context.addDiagnostic(createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, + errorInfo.diagnosticMessage, + symbolAccessibilityResult.errorSymbolName, + symbolAccessibilityResult.errorModuleName)); + } + return true; + } + } + return false; + } + + function trackExternalModuleSymbolOfImportTypeNode(symbol: Symbol) { + if (!isBundledEmit) { + (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol); + } + } + + function trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) { + if (symbol.flags & SymbolFlags.TypeParameter) return false; + const issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); + recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); + return issuedDiagnostic; + } + + function reportPrivateInBaseOfClassExpression(propertyName: string) { + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic( + createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); + } + } + + function errorDeclarationNameWithFallback() { + return errorNameNode ? declarationNameToString(errorNameNode) : + errorFallbackNode && getNameOfDeclaration(errorFallbackNode) ? declarationNameToString(getNameOfDeclaration(errorFallbackNode)) : + errorFallbackNode && isExportAssignment(errorFallbackNode) ? errorFallbackNode.isExportEquals ? "export=" : "default" : + "(Missing)"; // same fallback declarationNameToString uses when node is zero-width (ie, nameless) + } + + function reportInaccessibleUniqueSymbolError() { + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, + errorDeclarationNameWithFallback(), + "unique symbol")); + } + } + + function reportCyclicStructureError() { + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary, + errorDeclarationNameWithFallback())); + } + } + + function reportInaccessibleThisError() { + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, + errorDeclarationNameWithFallback(), + "this")); + } + } + + function reportLikelyUnsafeImportRequiredError(specifier: string) { + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, + errorDeclarationNameWithFallback(), + specifier)); + } + } + + function reportTruncationError() { + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); + } + } + + function reportNonlocalAugmentation(containingFile: SourceFile, parentSymbol: Symbol, symbol: Symbol) { + const primaryDeclaration = parentSymbol.declarations?.find(d => getSourceFileOfNode(d) === containingFile); + const augmentingDeclarations = filter(symbol.declarations, d => getSourceFileOfNode(d) !== containingFile); + if (primaryDeclaration && augmentingDeclarations) { + for (const augmentations of augmentingDeclarations) { + context.addDiagnostic(addRelatedInfo( + createDiagnosticForNode(augmentations, Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), + createDiagnosticForNode(primaryDeclaration, Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file) + )); + } + } + } + + function reportNonSerializableProperty(propertyName: string) { + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName)); + } + } + + function reportImportTypeNodeResolutionModeOverride() { + if (!isNightly() && (errorNameNode || errorFallbackNode)) { + context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next)); + } + } + + function transformDeclarationsForJS(sourceFile: SourceFile, bundled?: boolean) { + const oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = (s) => (s.errorNode && canProduceDiagnostics(s.errorNode) ? createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({ + diagnosticMessage: s.errorModuleName + ? Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + })); + const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; + } + + function transformRoot(node: Bundle): Bundle; + function transformRoot(node: SourceFile): SourceFile; + function transformRoot(node: SourceFile | Bundle): SourceFile | Bundle; + function transformRoot(node: SourceFile | Bundle) { + if (node.kind === SyntaxKind.SourceFile && node.isDeclarationFile) { + return node; + } + + if (node.kind === SyntaxKind.Bundle) { + isBundledEmit = true; + refs = new Map(); + libs = new Map(); + let hasNoDefaultLib = false; + const bundle = factory.createBundle(map(node.sourceFiles, + sourceFile => { + if (sourceFile.isDeclarationFile) return undefined!; // Omit declaration files from bundle results, too // TODO: GH#18217 + hasNoDefaultLib = hasNoDefaultLib || sourceFile.hasNoDefaultLib; + currentSourceFile = sourceFile; + enclosingDeclaration = sourceFile; + lateMarkedStatements = undefined; + suppressNewDiagnosticContexts = false; + lateStatementReplacementMap = new Map(); + getSymbolAccessibilityDiagnostic = throwDiagnostic; + needsScopeFixMarker = false; + resultHasScopeMarker = false; + collectReferences(sourceFile, refs); + collectLibs(sourceFile, libs); + if (isExternalOrCommonJsModule(sourceFile) || isJsonSourceFile(sourceFile)) { + resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) + needsDeclare = false; + const statements = isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : visitNodes(sourceFile.statements, visitDeclarationStatements, isStatement); + const newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration( + [factory.createModifier(SyntaxKind.DeclareKeyword)], + factory.createStringLiteral(getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), + factory.createModuleBlock(setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)) + )], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + return newFile; + } + needsDeclare = true; + const updated = isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : visitNodes(sourceFile.statements, visitDeclarationStatements, isStatement); + return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + } + ), mapDefined(node.prepends, prepend => { + if (prepend.kind === SyntaxKind.InputFiles) { + const sourceFile = createUnparsedSourceFile(prepend, "dts", stripInternal); + hasNoDefaultLib = hasNoDefaultLib || !!sourceFile.hasNoDefaultLib; + collectReferences(sourceFile, refs); + recordTypeReferenceDirectivesIfNecessary(map(sourceFile.typeReferenceDirectives, ref => [ref.fileName, ref.resolutionMode])); + collectLibs(sourceFile, libs); + return sourceFile; + } + return prepend; + })); + bundle.syntheticFileReferences = []; + bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences(); + bundle.syntheticLibReferences = getLibReferences(); + bundle.hasNoDefaultLib = hasNoDefaultLib; + const outputFilePath = getDirectoryPath(normalizeSlashes(getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath!)); + const referenceVisitor = mapReferencesIntoArray(bundle.syntheticFileReferences as FileReference[], outputFilePath); + refs.forEach(referenceVisitor); + return bundle; + } + + // Single source file + needsDeclare = true; + needsScopeFixMarker = false; + resultHasScopeMarker = false; + enclosingDeclaration = node; + currentSourceFile = node; + getSymbolAccessibilityDiagnostic = throwDiagnostic; + isBundledEmit = false; + resultHasExternalModuleIndicator = false; + suppressNewDiagnosticContexts = false; + lateMarkedStatements = undefined; + lateStatementReplacementMap = new Map(); + necessaryTypeReferences = undefined; + refs = collectReferences(currentSourceFile, new Map()); + libs = collectLibs(currentSourceFile, new Map()); + const references: FileReference[] = []; + const outputFilePath = getDirectoryPath(normalizeSlashes(getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath!)); + const referenceVisitor = mapReferencesIntoArray(references, outputFilePath); + let combinedStatements: NodeArray; + if (isSourceFileJS(currentSourceFile)) { + combinedStatements = factory.createNodeArray(transformDeclarationsForJS(node)); + refs.forEach(referenceVisitor); + emittedImports = filter(combinedStatements, isAnyImportSyntax); + } + else { + const statements = visitNodes(node.statements, visitDeclarationStatements, isStatement); + combinedStatements = setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = filter(combinedStatements, isAnyImportSyntax); + if (isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = setTextRange(factory.createNodeArray([...combinedStatements, createEmptyExports(factory)]), combinedStatements); + } + } + const typeReferences = isolatedDeclarations? node.typeReferenceDirectives: getFileReferencesForUsedTypeReferences(); + const updated = factory.updateSourceFile(node, combinedStatements, /*isDeclarationFile*/ true, references, typeReferences, node.hasNoDefaultLib, getLibReferences()); + updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; + return updated; + + function getLibReferences() { + return arrayFrom(libs.keys(), lib => ({ fileName: lib, pos: -1, end: -1 })); + } + + function getFileReferencesForUsedTypeReferences() { + return necessaryTypeReferences ? mapDefined(arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : []; + } + + function getFileReferenceForSpecifierModeTuple([typeName, mode]: [specifier: string, mode: ResolutionMode]): FileReference | undefined { + // Elide type references for which we have imports + if (emittedImports) { + for (const importStatement of emittedImports) { + if (isImportEqualsDeclaration(importStatement) && isExternalModuleReference(importStatement.moduleReference)) { + const expr = importStatement.moduleReference.expression; + if (isStringLiteralLike(expr) && expr.text === typeName) { + return undefined; + } + } + else if (isImportDeclaration(importStatement) && isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) { + return undefined; + } + } + } + return { fileName: typeName, pos: -1, end: -1, ...(mode ? { resolutionMode: mode } : undefined) }; + } + + function mapReferencesIntoArray(references: FileReference[], outputFilePath: string): (file: SourceFile) => void { + return file => { + let fileName = file.fileName; + if(!fileName.endsWith(".d.ts") && fileName.endsWith(".ts")) { + fileName = fileName.substring(0, fileName.length - 3) + ".d.ts"; + } + references.push({ pos: -1, end: -1, fileName }); + }; + } + } + + function collectReferences(sourceFile: SourceFile | UnparsedSource, ret: Map) { + if (noResolve || (!isUnparsedSource(sourceFile) && isSourceFileJS(sourceFile))) return ret; + forEach(sourceFile.referencedFiles, f => { + const elem = host.getSourceFileFromReference(sourceFile, f); + if (elem) { + ret.set(getOriginalNodeId(elem), elem); + } + }); + return ret; + } + + function collectLibs(sourceFile: SourceFile | UnparsedSource, ret: Map) { + forEach(sourceFile.libReferenceDirectives, ref => { + const lib = host.getLibFileFromReference(ref); + if (lib) { + ret.set(toFileNameLowerCase(ref.fileName), true); + } + }); + return ret; + } + + function filterBindingPatternInitializersAndRenamings(name: BindingName) { + if (name.kind === SyntaxKind.Identifier) { + return name; + } + else { + if (name.kind === SyntaxKind.ArrayBindingPattern) { + return factory.updateArrayBindingPattern(name, visitNodes(name.elements, visitBindingElement, isArrayBindingElement)); + } + else { + return factory.updateObjectBindingPattern(name, visitNodes(name.elements, visitBindingElement, isBindingElement)); + } + } + + function visitBindingElement(elem: T): T; + function visitBindingElement(elem: ArrayBindingElement): ArrayBindingElement { + if (elem.kind === SyntaxKind.OmittedExpression) { + return elem; + } + if (elem.propertyName && isIdentifier(elem.propertyName) && isIdentifier(elem.name) + // TODO: isolated declarations: find a better way for this since we don't actually do signature usage analysis + && !isolatedDeclarations && !elem.symbol.isReferenced && !isIdentifierANonContextualKeyword(elem.propertyName)) { + // Unnecessary property renaming is forbidden in types, so remove renaming + return factory.updateBindingElement( + elem, + elem.dotDotDotToken, + /* propertyName */ undefined, + elem.propertyName, + shouldPrintWithInitializer(elem) ? elem.initializer : undefined + ); + } + return factory.updateBindingElement( + elem, + elem.dotDotDotToken, + elem.propertyName, + filterBindingPatternInitializersAndRenamings(elem.name), + shouldPrintWithInitializer(elem) ? elem.initializer : undefined + ); + } + } + + function ensureParameter(p: ParameterDeclaration, modifierMask?: ModifierFlags, type?: TypeNode): ParameterDeclaration { + let oldDiag: typeof getSymbolAccessibilityDiagnostic | undefined; + if (!suppressNewDiagnosticContexts) { + oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(p); + } + const newParam = factory.updateParameterDeclaration( + p, + maskModifiers(factory, p, modifierMask), + p.dotDotDotToken, + filterBindingPatternInitializersAndRenamings(p.name), + resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(SyntaxKind.QuestionToken)) : undefined, + ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + ensureNoInitializer(p) + ); + if (!suppressNewDiagnosticContexts) { + getSymbolAccessibilityDiagnostic = oldDiag!; + } + return newParam; + } + + function shouldPrintWithInitializer(node: Node) { + return canHaveLiteralInitializer(node) && resolver.isLiteralConstDeclaration(getParseTreeNode(node) as CanHaveLiteralInitializer); // TODO: Make safe + } + + function ensureNoInitializer(node: CanHaveLiteralInitializer) { + if (shouldPrintWithInitializer(node)) { + return resolver.createLiteralConstValue(getParseTreeNode(node) as CanHaveLiteralInitializer, symbolTracker); // TODO: Make safe + } + return undefined; + } + + type HasInferredType = + | FunctionDeclaration + | MethodDeclaration + | GetAccessorDeclaration + | SetAccessorDeclaration + | BindingElement + | ConstructSignatureDeclaration + | VariableDeclaration + | MethodSignature + | CallSignatureDeclaration + | ParameterDeclaration + | PropertyDeclaration + | PropertySignature; + function makeInvalidType() { + return factory.createTypeReferenceNode("invalid"); + } + function ensureType(node: HasInferredType, type: TypeNode | undefined, ignorePrivate?: boolean): TypeNode | undefined { + if (!ignorePrivate && hasEffectiveModifier(node, ModifierFlags.Private)) { + // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) + return; + } + if (shouldPrintWithInitializer(node)) { + // Literal const declarations will have an initializer ensured rather than a type + return; + } + if (isolatedDeclarations) { + if (type === undefined) { + reportIsolatedDeclarationError(node); + return makeInvalidType(); + } + return visitNode(type, visitDeclarationSubtree, isTypeNode); + } + const shouldUseResolverType = node.kind === SyntaxKind.Parameter && + (resolver.isRequiredInitializedParameter(node) || + resolver.isOptionalUninitializedParameterProperty(node)); + if (type && !shouldUseResolverType) { + return visitNode(type, visitDeclarationSubtree, isTypeNode); + } + if (!getParseTreeNode(node)) { + return type ? visitNode(type, visitDeclarationSubtree, isTypeNode) : factory.createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + if (node.kind === SyntaxKind.SetAccessor) { + // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now + // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) + return factory.createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + errorNameNode = node.name; + let oldDiag: typeof getSymbolAccessibilityDiagnostic; + if (!suppressNewDiagnosticContexts) { + oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(node); + } + if (node.kind === SyntaxKind.VariableDeclaration || node.kind === SyntaxKind.BindingElement) { + return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); + } + if (node.kind === SyntaxKind.Parameter + || node.kind === SyntaxKind.PropertyDeclaration + || node.kind === SyntaxKind.PropertySignature) { + if (isPropertySignature(node) || !node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); + return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); + } + return cleanup(resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); + + function cleanup(returnValue: TypeNode | undefined) { + errorNameNode = undefined; + if (!suppressNewDiagnosticContexts) { + getSymbolAccessibilityDiagnostic = oldDiag; + } + return returnValue || factory.createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + } + + function isDeclarationAndNotVisible(node: NamedDeclaration) { + node = getParseTreeNode(node) as NamedDeclaration; + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.EnumDeclaration: + return !resolver.isDeclarationVisible(node); + // The following should be doing their own visibility checks based on filtering their members + case SyntaxKind.VariableDeclaration: + return !getBindingNameVisible(node as VariableDeclaration); + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ExportDeclaration: + case SyntaxKind.ExportAssignment: + return false; + case SyntaxKind.ClassStaticBlockDeclaration: + return true; + } + return false; + } + + // If the ExpandoFunctionDeclaration have multiple overloads, then we only need to emit properties for the last one. + function shouldEmitFunctionProperties(input: FunctionDeclaration) { + if (input.body) { + return true; + } + + const overloadSignatures = input.symbol.declarations?.filter(decl => isFunctionDeclaration(decl) && !decl.body); + return !overloadSignatures || overloadSignatures.indexOf(input) === overloadSignatures.length - 1; + } + + function getBindingNameVisible(elem: BindingElement | VariableDeclaration | OmittedExpression): boolean { + if (isOmittedExpression(elem)) { + return false; + } + if (isBindingPattern(elem.name)) { + // If any child binding pattern element has been marked visible (usually by collect linked aliases), then this is visible + return some(elem.name.elements, getBindingNameVisible); + } + else { + return resolver.isDeclarationVisible(elem); + } + } + + function updateParamsList(node: Node, params: NodeArray, modifierMask?: ModifierFlags): NodeArray { + if (hasEffectiveModifier(node, ModifierFlags.Private)) { + return factory.createNodeArray(); + } + const newParams = map(params, p => ensureParameter(p, modifierMask)); + if (!newParams) { + return factory.createNodeArray(); + } + return factory.createNodeArray(newParams, params.hasTrailingComma); + } + + function updateAccessorParamsList(input: AccessorDeclaration, isPrivate: boolean) { + let newParams: ParameterDeclaration[] | undefined; + if (!isPrivate) { + const thisParameter = getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (isSetAccessorDeclaration(input)) { + let newValueParameter: ParameterDeclaration | undefined; + if (!isPrivate) { + const valueParameter = getSetAccessorValueParameter(input); + if (valueParameter) { + const accessorType = + isolatedDeclarations ? + undefined: + getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = factory.createParameterDeclaration( + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + "value" + ); + } + newParams = append(newParams, newValueParameter); + } + return factory.createNodeArray(newParams || emptyArray); + } + + function ensureTypeParams(node: Node, params: NodeArray | undefined) { + return hasEffectiveModifier(node, ModifierFlags.Private) ? undefined : visitNodes(params, visitDeclarationSubtree, isTypeParameterDeclaration); + } + + function isEnclosingDeclaration(node: Node) { + return isSourceFile(node) + || isTypeAliasDeclaration(node) + || isModuleDeclaration(node) + || isClassDeclaration(node) + || isInterfaceDeclaration(node) + || isFunctionLike(node) + || isIndexSignatureDeclaration(node) + || isMappedTypeNode(node); + } + + function checkEntityNameVisibility(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node) { + const visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration); + handleSymbolAccessibilityError(visibilityResult); + recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); + } + + function preserveJsDoc(updated: T, original: Node): T { + if (hasJSDocNodes(updated) && hasJSDocNodes(original)) { + updated.jsDoc = original.jsDoc; + } + return setCommentRange(updated, getCommentRange(original)); + } + + function rewriteModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode, input: T | undefined): T | StringLiteral { + if (!input) return undefined!; // TODO: GH#18217 + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== SyntaxKind.ModuleDeclaration && parent.kind !== SyntaxKind.ImportType); + if (isStringLiteralLike(input)) { + if (isBundledEmit) { + const newName = getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); + if (newName) { + return factory.createStringLiteral(newName); + } + } + else { + const symbol = resolver.getSymbolOfExternalModuleSpecifier(input); + if (symbol) { + (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol); + } + } + } + return input; + } + + function transformImportEqualsDeclaration(decl: ImportEqualsDeclaration) { + if (!resolver.isDeclarationVisible(decl)) return; + if (decl.moduleReference.kind === SyntaxKind.ExternalModuleReference) { + // Rewrite external module names if necessary + const specifier = getExternalModuleImportEqualsDeclarationExpression(decl); + return factory.updateImportEqualsDeclaration( + decl, + decl.modifiers, + decl.isTypeOnly, + decl.name, + factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier)) + ); + } + else { + const oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(decl); + checkEntityNameVisibility(decl.moduleReference, enclosingDeclaration); + getSymbolAccessibilityDiagnostic = oldDiag; + return decl; + } + } + + function transformImportDeclaration(decl: ImportDeclaration) { + if (!decl.importClause) { + // import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc) + return factory.updateImportDeclaration( + decl, + decl.modifiers, + decl.importClause, + rewriteModuleSpecifier(decl, decl.moduleSpecifier), + getResolutionModeOverrideForClauseInNightly(decl.assertClause) + ); + } + // The `importClause` visibility corresponds to the default's visibility. + const visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; + if (!decl.importClause.namedBindings) { + // No named bindings (either namespace or list), meaning the import is just default or should be elided + return visibleDefaultBinding && factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause( + decl.importClause, + decl.importClause.isTypeOnly, + visibleDefaultBinding, + /*namedBindings*/ undefined, + ), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); + } + if (decl.importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { + // Namespace import (optionally with visible default) + const namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause( + decl.importClause, + decl.importClause.isTypeOnly, + visibleDefaultBinding, + namedBindings, + ), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; + } + // Named imports (optionally with visible default) + const bindingList = mapDefined(decl.importClause.namedBindings.elements, b => resolver.isDeclarationVisible(b) ? b : undefined); + if ((bindingList && bindingList.length) || visibleDefaultBinding) { + return factory.updateImportDeclaration( + decl, + decl.modifiers, + factory.updateImportClause( + decl.importClause, + decl.importClause.isTypeOnly, + visibleDefaultBinding, + bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined, + ), + rewriteModuleSpecifier(decl, decl.moduleSpecifier), + getResolutionModeOverrideForClauseInNightly(decl.assertClause) + ); + } + // Augmentation of export depends on import + if (resolver.isImportRequiredByAugmentation(decl)) { + if(isolatedDeclarations) { + // TODO: Should report better error here. Suggest we add the syntax import type '....' + // Also add a test for this. + reportIsolatedDeclarationError(decl); + return undefined; + } + return factory.updateImportDeclaration( + decl, + decl.modifiers, + /*importClause*/ undefined, + rewriteModuleSpecifier(decl, decl.moduleSpecifier), + getResolutionModeOverrideForClauseInNightly(decl.assertClause) + ); + } + // Nothing visible + } + + function getResolutionModeOverrideForClauseInNightly(assertClause: AssertClause | undefined) { + const mode = getResolutionModeOverrideForClause(assertClause); + if (mode !== undefined) { + if (!isNightly()) { + context.addDiagnostic(createDiagnosticForNode(assertClause!, Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next)); + } + return assertClause; + } + return undefined; + } + + function transformAndReplaceLatePaintedStatements(statements: NodeArray): NodeArray { + // This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during + // error handling which must now be included in the output and themselves checked for errors. + // For example: + // ``` + // module A { + // export module Q {} + // import B = Q; + // import C = B; + // export import D = C; + // } + // ``` + // In such a scenario, only Q and D are initially visible, but we don't consider imports as private names - instead we say they if they are referenced they must + // be recorded. So while checking D's visibility we mark C as visible, then we must check C which in turn marks B, completing the chain of + // dependent imports and allowing a valid declaration file output. Today, this dependent alias marking only happens for internal import aliases. + while (length(lateMarkedStatements)) { + const i = lateMarkedStatements!.shift()!; + if (!isLateVisibilityPaintedStatement(i)) { + return Debug.fail(`Late replaced statement was found which is not handled by the declaration transformer!: ${Debug.formatSyntaxKind((i as Node).kind)}`); + } + const priorNeedsDeclare = needsDeclare; + needsDeclare = i.parent && isSourceFile(i.parent) && !(isExternalModule(i.parent) && isBundledEmit); + const result = transformTopLevelDeclaration(i); + needsDeclare = priorNeedsDeclare; + lateStatementReplacementMap.set(getOriginalNodeId(i), result); + } + + // And lastly, we need to get the final form of all those indetermine import declarations from before and add them to the output list + // (and remove them from the set to examine for outter declarations) + return visitNodes(statements, visitLateVisibilityMarkedStatements, isStatement); + + function visitLateVisibilityMarkedStatements(statement: Statement) { + if (isLateVisibilityPaintedStatement(statement)) { + const key = getOriginalNodeId(statement); + if (lateStatementReplacementMap.has(key)) { + const result = lateStatementReplacementMap.get(key) as Statement | readonly Statement[] | undefined; + lateStatementReplacementMap.delete(key); + if (result) { + if (isArray(result) ? some(result, needsScopeMarker) : needsScopeMarker(result)) { + // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier + needsScopeFixMarker = true; + } + if (isSourceFile(statement.parent) && (isArray(result) ? some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + resultHasExternalModuleIndicator = true; + } + } + return result; + } + } + return statement; + } + } + + function visitDeclarationSubtree(input: Node): VisitResult { + if (shouldStripInternal(input)) return; + if (isDeclaration(input)) { + if (isDeclarationAndNotVisible(input)) return; + if (hasDynamicName(input) && !resolver.isLateBound(getParseTreeNode(input) as Declaration)) { + if (isolatedDeclarations && hasIdentifierComputedName(input)) { + reportIsolatedDeclarationError(input); + } + else { + return; + } + } + } + + // Elide implementation signatures from overload sets + if (isFunctionLike(input) && resolver.isImplementationOfOverload(input)) return; + + // Elide semicolon class statements + if (isSemicolonClassElement(input)) return; + + let previousEnclosingDeclaration: typeof enclosingDeclaration; + if (isEnclosingDeclaration(input)) { + previousEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = input as Declaration; + } + const oldDiag = getSymbolAccessibilityDiagnostic; + + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + const canProduceDiagnostic = canProduceDiagnostics(input); + const oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + let shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === SyntaxKind.TypeLiteral || input.kind === SyntaxKind.MappedType) && input.parent.kind !== SyntaxKind.TypeAliasDeclaration); + + // Emit methods which are private as properties with no type information + if (isMethodDeclaration(input) || isMethodSignature(input)) { + if (hasEffectiveModifier(input, ModifierFlags.Private)) { + if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload + return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); + } + } + + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input); + } + + if (isTypeQueryNode(input)) { + checkEntityNameVisibility(input.exprName, enclosingDeclaration); + } + + if (shouldEnterSuppressNewDiagnosticsContextContext) { + // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. + suppressNewDiagnosticContexts = true; + } + + if (isProcessedComponent(input)) { + switch (input.kind) { + case SyntaxKind.ExpressionWithTypeArguments: { + if ((isEntityName(input.expression) || isEntityNameExpression(input.expression))) { + checkEntityNameVisibility(input.expression, enclosingDeclaration); + } + const node = visitEachChild(input, visitDeclarationSubtree, context); + return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); + } + case SyntaxKind.TypeReference: { + checkEntityNameVisibility(input.typeName, enclosingDeclaration); + const node = visitEachChild(input, visitDeclarationSubtree, context); + return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); + } + case SyntaxKind.ConstructSignature: + return cleanup(factory.updateConstructSignature( + input, + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters), + ensureType(input, input.type) + )); + case SyntaxKind.Constructor: { + // A constructor declaration may not have a type annotation + const ctor = factory.createConstructorDeclaration( + /*modifiers*/ ensureModifiers(input), + updateParamsList(input, input.parameters, ModifierFlags.None), + /*body*/ undefined + ); + return cleanup(ctor); + } + case SyntaxKind.MethodDeclaration: { + if (isPrivateIdentifier(input.name)) { + return cleanup(/*returnValue*/ undefined); + } + const sig = factory.createMethodDeclaration( + ensureModifiers(input), + /*asteriskToken*/ undefined, + input.name, + input.questionToken, + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters), + ensureType(input, input.type), + /*body*/ undefined + ); + return cleanup(sig); + } + case SyntaxKind.GetAccessor: { + if (isPrivateIdentifier(input.name)) { + return cleanup(/*returnValue*/ undefined); + } + const accessorType = + isolatedDeclarations ? + input.type: + getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(factory.updateGetAccessorDeclaration( + input, + ensureModifiers(input), + input.name, + updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)), + ensureType(input, accessorType), + /*body*/ undefined)); + } + case SyntaxKind.SetAccessor: { + if (isPrivateIdentifier(input.name)) { + return cleanup(/*returnValue*/ undefined); + } + return cleanup(factory.updateSetAccessorDeclaration( + input, + ensureModifiers(input), + input.name, + updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)), + /*body*/ undefined)); + } + case SyntaxKind.PropertyDeclaration: + if (isPrivateIdentifier(input.name)) { + return cleanup(/*returnValue*/ undefined); + } + return cleanup(factory.updatePropertyDeclaration( + input, + ensureModifiers(input), + input.name, + input.questionToken, + ensureType(input, input.type), + ensureNoInitializer(input) + )); + case SyntaxKind.PropertySignature: + if (isPrivateIdentifier(input.name)) { + return cleanup(/*returnValue*/ undefined); + } + return cleanup(factory.updatePropertySignature( + input, + ensureModifiers(input), + input.name, + input.questionToken, + ensureType(input, input.type) + )); + case SyntaxKind.MethodSignature: { + if (isPrivateIdentifier(input.name)) { + return cleanup(/*returnValue*/ undefined); + } + return cleanup(factory.updateMethodSignature( + input, + ensureModifiers(input), + input.name, + input.questionToken, + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters), + ensureType(input, input.type) + )); + } + case SyntaxKind.CallSignature: { + return cleanup(factory.updateCallSignature( + input, + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters), + ensureType(input, input.type) + )); + } + case SyntaxKind.IndexSignature: { + return cleanup(factory.updateIndexSignature( + input, + ensureModifiers(input), + updateParamsList(input, input.parameters), + visitNode(input.type, visitDeclarationSubtree, isTypeNode) || factory.createKeywordTypeNode(SyntaxKind.AnyKeyword) + )); + } + case SyntaxKind.VariableDeclaration: { + if (isBindingPattern(input.name)) { + return recreateBindingPattern(input.name); + } + shouldEnterSuppressNewDiagnosticsContextContext = true; + suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types + return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); + } + case SyntaxKind.TypeParameter: { + if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { + return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); + } + return cleanup(visitEachChild(input, visitDeclarationSubtree, context)); + } + case SyntaxKind.ConditionalType: { + // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration + // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. + const checkType = visitNode(input.checkType, visitDeclarationSubtree, isTypeNode); + const extendsType = visitNode(input.extendsType, visitDeclarationSubtree, isTypeNode); + const oldEnclosingDecl = enclosingDeclaration; + enclosingDeclaration = input.trueType; + const trueType = visitNode(input.trueType, visitDeclarationSubtree, isTypeNode); + enclosingDeclaration = oldEnclosingDecl; + const falseType = visitNode(input.falseType, visitDeclarationSubtree, isTypeNode); + Debug.assert(checkType); + Debug.assert(extendsType); + Debug.assert(trueType); + Debug.assert(falseType); + return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); + } + case SyntaxKind.FunctionType: { + return cleanup(factory.updateFunctionTypeNode(input, visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration), updateParamsList(input, input.parameters), Debug.checkDefined(visitNode(input.type, visitDeclarationSubtree, isTypeNode)))); + } + case SyntaxKind.ConstructorType: { + return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration), updateParamsList(input, input.parameters), Debug.checkDefined(visitNode(input.type, visitDeclarationSubtree, isTypeNode)))); + } + case SyntaxKind.ImportType: { + if (!isLiteralImportTypeNode(input)) return cleanup(input); + return cleanup(factory.updateImportTypeNode( + input, + factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), + input.assertions, + input.qualifier, + visitNodes(input.typeArguments, visitDeclarationSubtree, isTypeNode), + input.isTypeOf + )); + } + default: Debug.assertNever(input, `Attempted to process unhandled node kind: ${Debug.formatSyntaxKind((input as Node).kind)}`); + } + } + + if (isTupleTypeNode(input) && (getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { + setEmitFlags(input, EmitFlags.SingleLine); + } + + return cleanup(visitEachChild(input, visitDeclarationSubtree, context)); + + function cleanup(returnValue: T | undefined): T | undefined { + if (returnValue && canProduceDiagnostic && hasDynamicName(input as Declaration)) { + checkName(input); + } + if (isEnclosingDeclaration(input)) { + enclosingDeclaration = previousEnclosingDeclaration; + } + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { + getSymbolAccessibilityDiagnostic = oldDiag; + } + if (shouldEnterSuppressNewDiagnosticsContextContext) { + suppressNewDiagnosticContexts = oldWithinObjectLiteralType; + } + if (returnValue === input) { + return returnValue; + } + return returnValue && setOriginalNode(preserveJsDoc(returnValue, input), input); + } + } + + function isPrivateMethodTypeParameter(node: TypeParameterDeclaration) { + return node.parent.kind === SyntaxKind.MethodDeclaration && hasEffectiveModifier(node.parent, ModifierFlags.Private); + } + + function visitDeclarationStatements(input: Node): VisitResult { + if (!isPreservedDeclarationStatement(input)) { + // return undefined for unmatched kinds to omit them from the tree + return; + } + if (shouldStripInternal(input)) return; + + switch (input.kind) { + case SyntaxKind.ExportDeclaration: { + if (isSourceFile(input.parent)) { + resultHasExternalModuleIndicator = true; + } + resultHasScopeMarker = true; + // Always visible if the parent node isn't dropped for being not visible + // Rewrite external module names if necessary + return factory.updateExportDeclaration( + input, + input.modifiers, + input.isTypeOnly, + input.exportClause, + rewriteModuleSpecifier(input, input.moduleSpecifier), + getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined + ); + } + case SyntaxKind.ExportAssignment: { + // Always visible if the parent node isn't dropped for being not visible + if (isSourceFile(input.parent)) { + resultHasExternalModuleIndicator = true; + } + resultHasScopeMarker = true; + if (input.expression.kind === SyntaxKind.Identifier) { + return input; + } + else { + const newId = factory.createUniqueName("_default", GeneratedIdentifierFlags.Optimistic); + getSymbolAccessibilityDiagnostic = () => ({ + diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: input + }); + errorFallbackNode = input; + if (isolatedDeclarations) { + reportIsolatedDeclarationError(input); + } + const type = isolatedDeclarations ? + makeInvalidType() : + resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker); + const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); + errorFallbackNode = undefined; + const statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(SyntaxKind.DeclareKeyword)] : [], factory.createVariableDeclarationList([varDecl], NodeFlags.Const)); + + preserveJsDoc(statement, input); + removeAllComments(input); + return [statement, factory.updateExportAssignment(input, input.modifiers, newId)]; + } + } + } + + const result = transformTopLevelDeclaration(input); + // Don't actually transform yet; just leave as original node - will be elided/swapped by late pass + lateStatementReplacementMap.set(getOriginalNodeId(input), result); + return input; + } + + function stripExportModifiers(statement: Statement): Statement { + if (isImportEqualsDeclaration(statement) || hasEffectiveModifier(statement, ModifierFlags.Default) || !canHaveModifiers(statement)) { + // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace + // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too + return statement; + } + + const modifiers = factory.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (ModifierFlags.All ^ ModifierFlags.Export)); + return factory.updateModifiers(statement, modifiers); + } + + function transformTopLevelDeclaration(input: LateVisibilityPaintedStatement) { + if (lateMarkedStatements) { + while (orderedRemoveItem(lateMarkedStatements, input)); + } + if (shouldStripInternal(input)) return; + switch (input.kind) { + case SyntaxKind.ImportEqualsDeclaration: { + return transformImportEqualsDeclaration(input); + } + case SyntaxKind.ImportDeclaration: { + return transformImportDeclaration(input); + } + } + if (isDeclaration(input) && isDeclarationAndNotVisible(input)) return; + + // Elide implementation signatures from overload sets + if (isFunctionLike(input) && resolver.isImplementationOfOverload(input)) return; + + let previousEnclosingDeclaration: typeof enclosingDeclaration; + if (isEnclosingDeclaration(input)) { + previousEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = input as Declaration; + } + + const canProdiceDiagnostic = canProduceDiagnostics(input); + const oldDiag = getSymbolAccessibilityDiagnostic; + if (canProdiceDiagnostic) { + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input as DeclarationDiagnosticProducing); + } + + const previousNeedsDeclare = needsDeclare; + switch (input.kind) { + case SyntaxKind.TypeAliasDeclaration: { + needsDeclare = false; + const clean = cleanup(factory.updateTypeAliasDeclaration( + input, + ensureModifiers(input), + input.name, + visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration), + Debug.checkDefined(visitNode(input.type, visitDeclarationSubtree, isTypeNode)) + )); + needsDeclare = previousNeedsDeclare; + return clean; + } + case SyntaxKind.InterfaceDeclaration: { + return cleanup(factory.updateInterfaceDeclaration( + input, + ensureModifiers(input), + input.name, + ensureTypeParams(input, input.typeParameters), + transformHeritageClauses(input.heritageClauses), + visitNodes(input.members, visitDeclarationSubtree, isTypeElement) + )); + } + case SyntaxKind.FunctionDeclaration: { + // Generators lose their generator-ness, excepting their return type + const clean = cleanup(factory.updateFunctionDeclaration( + input, + ensureModifiers(input), + /*asteriskToken*/ undefined, + input.name, + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters), + ensureType(input, input.type), + /*body*/ undefined + )); + const isExpandoFunctionDeclaration = clean && resolver.isExpandoFunctionDeclaration(input); + if (isExpandoFunctionDeclaration && shouldEmitFunctionProperties(input)) { + if(isExpandoFunctionDeclaration && isolatedDeclarations) { + reportIsolatedDeclarationError(input); + return clean; + } + return clean; + } + else { + return clean; + } + } + case SyntaxKind.ModuleDeclaration: { + needsDeclare = false; + const inner = input.body; + if (inner && inner.kind === SyntaxKind.ModuleBlock) { + const oldNeedsScopeFix = needsScopeFixMarker; + const oldHasScopeFix = resultHasScopeMarker; + resultHasScopeMarker = false; + needsScopeFixMarker = false; + const statements = visitNodes(inner.statements, visitDeclarationStatements, isStatement); + let lateStatements = transformAndReplaceLatePaintedStatements(statements); + // TODO: isolatedDeclarations: See why Ambient si needed here + if (input.flags & (NodeFlags as any).Ambient) { + needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" + } + // With the final list of statements, there are 3 possibilities: + // 1. There's an export assignment or export declaration in the namespace - do nothing + // 2. Everything is exported and there are no export assignments or export declarations - strip all export modifiers + // 3. Some things are exported, some are not, and there's no marker - add an empty marker + if (!isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { + if (needsScopeFixMarker) { + lateStatements = factory.createNodeArray([...lateStatements, createEmptyExports(factory)]); + } + else { + lateStatements = visitNodes(lateStatements, stripExportModifiers, isStatement); + } + } + const body = factory.updateModuleBlock(inner, lateStatements); + needsDeclare = previousNeedsDeclare; + needsScopeFixMarker = oldNeedsScopeFix; + resultHasScopeMarker = oldHasScopeFix; + const mods = ensureModifiers(input); + return cleanup(factory.updateModuleDeclaration( + input, + mods, + isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, + body + )); + } + else { + needsDeclare = previousNeedsDeclare; + const mods = ensureModifiers(input); + needsDeclare = false; + visitNode(inner, visitDeclarationStatements); + // eagerly transform nested namespaces (the nesting doesn't need any elision or painting done) + const id = getOriginalNodeId(inner!); // TODO: GH#18217 + const body = lateStatementReplacementMap.get(id); + lateStatementReplacementMap.delete(id); + return cleanup(factory.updateModuleDeclaration( + input, + mods, + input.name, + body as ModuleBody + )); + } + } + case SyntaxKind.ClassDeclaration: { + errorNameNode = input.name; + errorFallbackNode = input; + const modifiers = factory.createNodeArray(ensureModifiers(input)); + const typeParameters = ensureTypeParams(input, input.typeParameters); + const ctor = getFirstConstructorWithBody(input); + let parameterProperties: readonly PropertyDeclaration[] | undefined; + if (ctor) { + const oldDiag = getSymbolAccessibilityDiagnostic; + parameterProperties = compact(flatMap(ctor.parameters, (param) => { + if (!hasSyntacticModifier(param, ModifierFlags.ParameterPropertyModifier) || shouldStripInternal(param)) return; + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(param); + if (param.name.kind === SyntaxKind.Identifier) { + return preserveJsDoc(factory.createPropertyDeclaration( + ensureModifiers(param), + param.name, + param.questionToken, + ensureType(param, param.type), + ensureNoInitializer(param)), param); + } + else { + // Pattern - this is currently an error, but we emit declarations for it somewhat correctly + return walkBindingPattern(param.name); + } + + function walkBindingPattern(pattern: BindingPattern) { + let elems: PropertyDeclaration[] | undefined; + for (const elem of pattern.elements) { + if (isOmittedExpression(elem)) continue; + if (isBindingPattern(elem.name)) { + elems = concatenate(elems, walkBindingPattern(elem.name)); + } + elems = elems || []; + elems.push(factory.createPropertyDeclaration( + ensureModifiers(param), + elem.name as Identifier, + /*questionToken*/ undefined, + ensureType(elem, /*type*/ undefined), + /*initializer*/ undefined + )); + } + return elems; + } + })); + getSymbolAccessibilityDiagnostic = oldDiag; + } + + const hasPrivateIdentifier = some(input.members, member => !!member.name && isPrivateIdentifier(member.name)); + // When the class has at least one private identifier, create a unique constant identifier to retain the nominal typing behavior + // Prevents other classes with the same public members from being used in place of the current class + const privateIdentifier = hasPrivateIdentifier ? [ + factory.createPropertyDeclaration( + /*modifiers*/ undefined, + factory.createPrivateIdentifier("#private"), + /*questionToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined + ) + ] : undefined; + const memberNodes = concatenate(concatenate(privateIdentifier, parameterProperties), visitNodes(input.members, visitDeclarationSubtree, isClassElement)); + const members = factory.createNodeArray(memberNodes); + + const extendsClause = getEffectiveBaseTypeNode(input); + if (extendsClause && !isEntityNameExpression(extendsClause.expression) && extendsClause.expression.kind !== SyntaxKind.NullKeyword) { + // We must add a temporary declaration for the extends clause expression + + // Isolated declarations does not allow inferred type in the extends clause + if(isolatedDeclarations) { + reportIsolatedDeclarationError(extendsClause); + return cleanup(factory.updateClassDeclaration( + input, + modifiers, + input.name, + typeParameters, + factory.createNodeArray([factory.createHeritageClause(SyntaxKind.ExtendsKeyword, + [ + factory.createExpressionWithTypeArguments( + factory.createIdentifier("invalid"), + /* typeArguments */ undefined, + ) + ])]), + members + )); + } + const oldId = input.name ? unescapeLeadingUnderscores(input.name.escapedText) : "default"; + const newId = factory.createUniqueName(`${oldId}_base`, GeneratedIdentifierFlags.Optimistic); + getSymbolAccessibilityDiagnostic = () => ({ + diagnosticMessage: Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, + errorNode: extendsClause, + typeName: input.name + }); + const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); + const statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(SyntaxKind.DeclareKeyword)] : [], factory.createVariableDeclarationList([varDecl], NodeFlags.Const)); + const heritageClauses = factory.createNodeArray(map(input.heritageClauses, clause => { + if (clause.token === SyntaxKind.ExtendsKeyword) { + const oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); + const newClause = factory.updateHeritageClause(clause, map(clause.types, t => factory.updateExpressionWithTypeArguments(t, newId, visitNodes(t.typeArguments, visitDeclarationSubtree, isTypeNode)))); + getSymbolAccessibilityDiagnostic = oldDiag; + return newClause; + } + return factory.updateHeritageClause(clause, visitNodes(factory.createNodeArray(filter(clause.types, t => isEntityNameExpression(t.expression) || t.expression.kind === SyntaxKind.NullKeyword)), visitDeclarationSubtree, isExpressionWithTypeArguments)); + })); + return [statement, cleanup(factory.updateClassDeclaration( + input, + modifiers, + input.name, + typeParameters, + heritageClauses, + members + ))!]; // TODO: GH#18217 + } + else { + const heritageClauses = transformHeritageClauses(input.heritageClauses); + return cleanup(factory.updateClassDeclaration( + input, + modifiers, + input.name, + typeParameters, + heritageClauses, + members + )); + } + } + case SyntaxKind.VariableStatement: { + return cleanup(transformVariableStatement(input)); + } + case SyntaxKind.EnumDeclaration: { + return cleanup(factory.updateEnumDeclaration(input, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(mapDefined(input.members, m => { + if (shouldStripInternal(m)) return; + if (isolatedDeclarations) { + if (m.initializer && !isLiteralExpression(m.initializer)) { + reportIsolatedDeclarationError(m); + } + return m; + } + // Rewrite enum values to their constants, if available + const constValue = isolatedDeclarations? undefined : resolver.getConstantValue(m); + return preserveJsDoc(factory.updateEnumMember(m, m.name, constValue !== undefined ? typeof constValue === "string" ? factory.createStringLiteral(constValue) : factory.createNumericLiteral(constValue) : undefined), m); + })))); + } + } + // Anything left unhandled is an error, so this should be unreachable + return Debug.assertNever(input, `Unhandled top-level node in declaration emit: ${Debug.formatSyntaxKind((input as Node).kind)}`); + + function cleanup(node: T | undefined): T | undefined { + if (isEnclosingDeclaration(input)) { + enclosingDeclaration = previousEnclosingDeclaration; + } + if (canProdiceDiagnostic) { + getSymbolAccessibilityDiagnostic = oldDiag; + } + if (input.kind === SyntaxKind.ModuleDeclaration) { + needsDeclare = previousNeedsDeclare; + } + if (node as Node === input) { + return node; + } + errorFallbackNode = undefined; + errorNameNode = undefined; + return node && setOriginalNode(preserveJsDoc(node, input), input); + } + } + + function transformVariableStatement(input: VariableStatement) { + if (!forEach(input.declarationList.declarations, getBindingNameVisible)) return; + const nodes = visitNodes(input.declarationList.declarations, visitDeclarationSubtree, isVariableDeclaration); + if (!length(nodes)) return; + return factory.updateVariableStatement(input, factory.createNodeArray(ensureModifiers(input)), factory.updateVariableDeclarationList(input.declarationList, nodes)); + } + + function recreateBindingPattern(d: BindingPattern): VariableDeclaration[] { + return flatten(mapDefined(d.elements, e => recreateBindingElement(e))); + } + + function recreateBindingElement(e: ArrayBindingElement) { + if (e.kind === SyntaxKind.OmittedExpression) { + return; + } + if (e.name) { + if (!getBindingNameVisible(e)) return; + if (isBindingPattern(e.name)) { + return recreateBindingPattern(e.name); + } + else { + return factory.createVariableDeclaration(e.name, /*exclamationToken*/ undefined, ensureType(e, /*type*/ undefined), /*initializer*/ undefined); + } + } + } + + function checkName(node: DeclarationDiagnosticProducing) { + let oldDiag: typeof getSymbolAccessibilityDiagnostic | undefined; + if (!suppressNewDiagnosticContexts) { + oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNodeName(node); + } + errorNameNode = (node as NamedDeclaration).name; + const decl = node as NamedDeclaration as LateBoundDeclaration; + + Debug.assert((hasIdentifierComputedName(decl) && options.isolatedDeclarations) || resolver.isLateBound(getParseTreeNode(node) as Declaration)); // Should only be called with dynamic names + const entityName = decl.name.expression; + checkEntityNameVisibility(entityName, enclosingDeclaration); + if (!suppressNewDiagnosticContexts) { + getSymbolAccessibilityDiagnostic = oldDiag!; + } + errorNameNode = undefined; + } + + function shouldStripInternal(node: Node) { + return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile); + } + + function isScopeMarker(node: Node) { + return isExportAssignment(node) || isExportDeclaration(node); + } + + function hasScopeMarker(statements: readonly Statement[]) { + return some(statements, isScopeMarker); + } + + function ensureModifiers(node: T): readonly Modifier[] | undefined { + const currentFlags = getEffectiveModifierFlags(node); + const newFlags = ensureModifierFlags(node); + if (currentFlags === newFlags) { + return visitArray(node.modifiers, n => tryCast(n, isModifier), isModifier); + } + return factory.createModifiersFromModifierFlags(newFlags); + } + + function ensureModifierFlags(node: Node): ModifierFlags { + let mask = ModifierFlags.All ^ (ModifierFlags.Public | ModifierFlags.Async | ModifierFlags.Override); // No async and override modifiers in declaration files + let additions = (needsDeclare && !isAlwaysType(node)) ? ModifierFlags.Ambient : ModifierFlags.None; + const parentIsFile = node.parent.kind === SyntaxKind.SourceFile; + if (!parentIsFile || (isBundledEmit && parentIsFile && isExternalModule(node.parent as SourceFile))) { + mask ^= ModifierFlags.Ambient; + additions = ModifierFlags.None; + } + return maskModifierFlags(node, mask, additions); + } + + function getTypeAnnotationFromAllAccessorDeclarations(node: AccessorDeclaration, accessors: AllAccessorDeclarations) { + let accessorType = getTypeAnnotationFromAccessor(node); + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); + } + return accessorType; + } + + function transformHeritageClauses(nodes: NodeArray | undefined) { + return factory.createNodeArray(filter(map(nodes, clause => factory.updateHeritageClause(clause, visitNodes(factory.createNodeArray(filter(clause.types, t => { + return isEntityNameExpression(t.expression) || (clause.token === SyntaxKind.ExtendsKeyword && t.expression.kind === SyntaxKind.NullKeyword); + })), visitDeclarationSubtree, isExpressionWithTypeArguments))), clause => clause.types && !!clause.types.length)); + } +} + +function isAlwaysType(node: Node) { + if (node.kind === SyntaxKind.InterfaceDeclaration) { + return true; + } + return false; +} + +// Elide "public" modifier, as it is the default +function maskModifiers(factory: NodeFactory, node: Node, modifierMask?: ModifierFlags, modifierAdditions?: ModifierFlags): Modifier[] | undefined { + return factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); +} + +function maskModifierFlags(node: Node, modifierMask: ModifierFlags = ModifierFlags.All ^ ModifierFlags.Public, modifierAdditions: ModifierFlags = ModifierFlags.None): ModifierFlags { + let flags = (getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; + if (flags & ModifierFlags.Default && !(flags & ModifierFlags.Export)) { + // A non-exported default is a nonsequitor - we usually try to remove all export modifiers + // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid + flags ^= ModifierFlags.Export; + } + if (flags & ModifierFlags.Default && flags & ModifierFlags.Ambient) { + flags ^= ModifierFlags.Ambient; // `declare` is never required alongside `default` (and would be an error if printed) + } + return flags; +} + +function getTypeAnnotationFromAccessor(accessor: AccessorDeclaration): TypeNode | undefined { + if (accessor) { + return accessor.kind === SyntaxKind.GetAccessor + ? accessor.type // Getter - return type + : accessor.parameters.length > 0 + ? accessor.parameters[0].type // Setter parameter type + : undefined; + } +} + +type CanHaveLiteralInitializer = VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration; +function canHaveLiteralInitializer(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + return !hasEffectiveModifier(node, ModifierFlags.Private); + case SyntaxKind.Parameter: + case SyntaxKind.VariableDeclaration: + return true; + } + return false; +} + +type ProcessedDeclarationStatement = + | FunctionDeclaration + | ModuleDeclaration + | ImportEqualsDeclaration + | InterfaceDeclaration + | ClassDeclaration + | TypeAliasDeclaration + | EnumDeclaration + | VariableStatement + | ImportDeclaration + | ExportDeclaration + | ExportAssignment; + +function isPreservedDeclarationStatement(node: Node): node is ProcessedDeclarationStatement { + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.VariableStatement: + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ExportDeclaration: + case SyntaxKind.ExportAssignment: + return true; + } + return false; +} + +type ProcessedComponent = + | ConstructSignatureDeclaration + | ConstructorDeclaration + | MethodDeclaration + | GetAccessorDeclaration + | SetAccessorDeclaration + | PropertyDeclaration + | PropertySignature + | MethodSignature + | CallSignatureDeclaration + | IndexSignatureDeclaration + | VariableDeclaration + | TypeParameterDeclaration + | ExpressionWithTypeArguments + | TypeReferenceNode + | ConditionalTypeNode + | FunctionTypeNode + | ConstructorTypeNode + | ImportTypeNode; + +function isProcessedComponent(node: Node): node is ProcessedComponent { + switch (node.kind) { + case SyntaxKind.ConstructSignature: + case SyntaxKind.Constructor: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.MethodSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.IndexSignature: + case SyntaxKind.VariableDeclaration: + case SyntaxKind.TypeParameter: + case SyntaxKind.ExpressionWithTypeArguments: + case SyntaxKind.TypeReference: + case SyntaxKind.ConditionalType: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + case SyntaxKind.ImportType: + return true; + } + return false; +} diff --git a/external-declarations/src/compiler/diagnosticInformationMap.generated.ts b/external-declarations/src/compiler/diagnosticInformationMap.generated.ts new file mode 100644 index 0000000000000..e4d7ed614ed3f --- /dev/null +++ b/external-declarations/src/compiler/diagnosticInformationMap.generated.ts @@ -0,0 +1,1893 @@ +// +// generated from 'src/compiler/diagnosticMessages.json' + +import { DiagnosticCategory, DiagnosticMessage } from "typescript"; + + +function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}, elidedInCompatabilityPyramid?: boolean, reportsDeprecated?: {}): DiagnosticMessage { + return { code, category, key, message, reportsUnnecessary, reportsDeprecated }; +} + +/** @internal */ +export const Diagnostics = { + Unterminated_string_literal: diag(1002, DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), + Identifier_expected: diag(1003, DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), + _0_expected: diag(1005, DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), + A_file_cannot_have_a_reference_to_itself: diag(1006, DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), + The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."), + Trailing_comma_not_allowed: diag(1009, DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), + Asterisk_Slash_expected: diag(1010, DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), + An_element_access_expression_should_take_an_argument: diag(1011, DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), + Unexpected_token: diag(1012, DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), + A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), + A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), + Parameter_cannot_have_question_mark_and_initializer: diag(1015, DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), + A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), + An_index_signature_cannot_have_a_rest_parameter: diag(1017, DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), + An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), + An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), + An_index_signature_parameter_cannot_have_an_initializer: diag(1020, DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), + An_index_signature_must_have_a_type_annotation: diag(1021, DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), + An_index_signature_parameter_must_have_a_type_annotation: diag(1022, DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), + An_index_signature_cannot_have_a_trailing_comma: diag(1025, DiagnosticCategory.Error, "An_index_signature_cannot_have_a_trailing_comma_1025", "An index signature cannot have a trailing comma."), + Accessibility_modifier_already_seen: diag(1028, DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), + _0_modifier_must_precede_1_modifier: diag(1029, DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), + _0_modifier_already_seen: diag(1030, DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), + _0_modifier_cannot_appear_on_class_elements_of_this_kind: diag(1031, DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_class_elements_of_this_kind_1031", "'{0}' modifier cannot appear on class elements of this kind."), + super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), + Only_ambient_modules_can_use_quoted_names: diag(1035, DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), + Statements_are_not_allowed_in_ambient_contexts: diag(1036, DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), + Initializers_are_not_allowed_in_ambient_contexts: diag(1039, DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), + _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), + _0_modifier_cannot_be_used_here: diag(1042, DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), + _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), + Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), + A_rest_parameter_cannot_be_optional: diag(1047, DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), + A_rest_parameter_cannot_have_an_initializer: diag(1048, DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), + A_set_accessor_must_have_exactly_one_parameter: diag(1049, DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), + A_set_accessor_cannot_have_an_optional_parameter: diag(1051, DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), + A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), + A_set_accessor_cannot_have_rest_parameter: diag(1053, DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), + A_get_accessor_cannot_have_parameters: diag(1054, DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), + A_promise_must_have_a_then_method: diag(1059, DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), + Enum_member_must_have_initializer: diag(1061, DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), + An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise<{0}>'?"), + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), + _0_modifier_cannot_appear_on_a_type_member: diag(1070, DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), + _0_modifier_cannot_appear_on_an_index_signature: diag(1071, DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), + A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), + Invalid_reference_directive_syntax: diag(1084, DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), + _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), + _0_modifier_cannot_appear_on_a_parameter: diag(1090, DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), + Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), + Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), + An_accessor_cannot_have_type_parameters: diag(1094, DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), + A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), + An_index_signature_must_have_exactly_one_parameter: diag(1096, DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), + _0_list_cannot_be_empty: diag(1097, DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), + Type_parameter_list_cannot_be_empty: diag(1098, DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), + Type_argument_list_cannot_be_empty: diag(1099, DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), + Invalid_use_of_0_in_strict_mode: diag(1100, DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), + with_statements_are_not_allowed_in_strict_mode: diag(1101, DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), + delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), + for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1103, DiagnosticCategory.Error, "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103", "'for await' loops are only allowed within async functions and at the top levels of modules."), + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + The_left_hand_side_of_a_for_of_statement_may_not_be_async: diag(1106, DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_async_1106", "The left-hand side of a 'for...of' statement may not be 'async'."), + Jump_target_cannot_cross_function_boundary: diag(1107, DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), + A_return_statement_can_only_be_used_within_a_function_body: diag(1108, DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), + Expression_expected: diag(1109, DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), + Type_expected: diag(1110, DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), + Duplicate_label_0: diag(1114, DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), + An_object_literal_cannot_have_multiple_properties_with_the_same_name: diag(1117, DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_1117", "An object literal cannot have multiple properties with the same name."), + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), + An_export_assignment_cannot_have_modifiers: diag(1120, DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), + Octal_literals_are_not_allowed_in_strict_mode: diag(1121, DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), + Variable_declaration_list_cannot_be_empty: diag(1123, DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), + Digit_expected: diag(1124, DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), + Hexadecimal_digit_expected: diag(1125, DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), + Unexpected_end_of_text: diag(1126, DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), + Invalid_character: diag(1127, DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), + Declaration_or_statement_expected: diag(1128, DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), + Statement_expected: diag(1129, DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), + case_or_default_expected: diag(1130, DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), + Property_or_signature_expected: diag(1131, DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), + Enum_member_expected: diag(1132, DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), + Variable_declaration_expected: diag(1134, DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), + Argument_expression_expected: diag(1135, DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), + Property_assignment_expected: diag(1136, DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), + Expression_or_comma_expected: diag(1137, DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), + Parameter_declaration_expected: diag(1138, DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), + Type_parameter_declaration_expected: diag(1139, DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), + Type_argument_expected: diag(1140, DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), + String_literal_expected: diag(1141, DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), + Line_break_not_permitted_here: diag(1142, DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), + or_expected: diag(1144, DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), + or_JSX_element_expected: diag(1145, DiagnosticCategory.Error, "or_JSX_element_expected_1145", "'{' or JSX element expected."), + Declaration_expected: diag(1146, DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), + Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), + Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), + File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), + const_declarations_must_be_initialized: diag(1155, DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), + const_declarations_can_only_be_declared_inside_a_block: diag(1156, DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), + let_declarations_can_only_be_declared_inside_a_block: diag(1157, DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), + Unterminated_template_literal: diag(1160, DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), + Unterminated_regular_expression_literal: diag(1161, DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), + An_object_member_cannot_be_declared_optional: diag(1162, DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), + A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), + Computed_property_names_are_not_allowed_in_enums: diag(1164, DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), + A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type: diag(1166, DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_1166", "A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), + extends_clause_already_seen: diag(1172, DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), + extends_clause_must_precede_implements_clause: diag(1173, DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), + Classes_can_only_extend_a_single_class: diag(1174, DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), + implements_clause_already_seen: diag(1175, DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), + Interface_declaration_cannot_have_implements_clause: diag(1176, DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), + Binary_digit_expected: diag(1177, DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), + Octal_digit_expected: diag(1178, DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), + Unexpected_token_expected: diag(1179, DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), + Property_destructuring_pattern_expected: diag(1180, DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), + Array_element_destructuring_pattern_expected: diag(1181, DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), + A_destructuring_declaration_must_have_an_initializer: diag(1182, DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), + An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), + Modifiers_cannot_appear_here: diag(1184, DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), + Merge_conflict_marker_encountered: diag(1185, DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), + A_rest_element_cannot_have_an_initializer: diag(1186, DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), + A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), + An_import_declaration_cannot_have_modifiers: diag(1191, DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), + Module_0_has_no_default_export: diag(1192, DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), + An_export_declaration_cannot_have_modifiers: diag(1193, DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), + Export_declarations_are_not_permitted_in_a_namespace: diag(1194, DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), + export_Asterisk_does_not_re_export_a_default: diag(1195, DiagnosticCategory.Error, "export_Asterisk_does_not_re_export_a_default_1195", "'export *' does not re-export a default."), + Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified: diag(1196, DiagnosticCategory.Error, "Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified_1196", "Catch clause variable type annotation must be 'any' or 'unknown' if specified."), + Catch_clause_variable_cannot_have_an_initializer: diag(1197, DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), + Unterminated_Unicode_escape_sequence: diag(1199, DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), + Line_terminator_not_permitted_before_arrow: diag(1200, DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), + Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type: diag(1205, DiagnosticCategory.Error, "Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type_1205", "Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'."), + Decorators_are_not_valid_here: diag(1206, DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), + _0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module: diag(1208, DiagnosticCategory.Error, "_0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_imp_1208", "'{0}' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module."), + Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0: diag(1209, DiagnosticCategory.Error, "Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0_1209", "Invalid optional chain from new expression. Did you mean to call '{0}()'?"), + Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode: diag(1210, DiagnosticCategory.Error, "Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of__1210", "Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '{0}'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode."), + A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), + Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), + Generators_are_not_allowed_in_an_ambient_context: diag(1221, DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), + An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), + _0_tag_already_specified: diag(1223, DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), + Signature_0_must_be_a_type_predicate: diag(1224, DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), + Cannot_find_parameter_0: diag(1225, DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), + Type_predicate_0_is_not_assignable_to_1: diag(1226, DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), + Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), + A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), + An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."), + An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1232, DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1232", "An import declaration can only be used at the top level of a namespace or module."), + An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1233, DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1233", "An export declaration can only be used at the top level of a namespace or module."), + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), + A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module: diag(1235, DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module_1235", "A namespace declaration is only allowed at the top level of a namespace or module."), + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), + _0_modifier_cannot_be_used_with_1_modifier: diag(1243, DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), + Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), + An_interface_property_cannot_have_an_initializer: diag(1246, DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), + A_type_literal_property_cannot_have_an_initializer: diag(1247, DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), + A_class_member_cannot_have_the_0_keyword: diag(1248, DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), + A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), + A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), + A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_required_element_cannot_follow_an_optional_element: diag(1257, DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1258, DiagnosticCategory.Error, "A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration_1258", "A default export must be at the top level of a file or module declaration."), + Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), + Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."), + Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module: diag(1262, DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module_1262", "Identifier expected. '{0}' is a reserved word at the top-level of a module."), + Declarations_with_initializers_cannot_also_have_definite_assignment_assertions: diag(1263, DiagnosticCategory.Error, "Declarations_with_initializers_cannot_also_have_definite_assignment_assertions_1263", "Declarations with initializers cannot also have definite assignment assertions."), + Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."), + A_rest_element_cannot_follow_another_rest_element: diag(1265, DiagnosticCategory.Error, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."), + An_optional_element_cannot_follow_a_rest_element: diag(1266, DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."), + Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."), + An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."), + Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."), + Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."), + Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."), + A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled: diag(1272, DiagnosticCategory.Error, "A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_w_1272", "A type referenced in a decorated signature must be imported with 'import type' or a namespace import when 'isolatedModules' and 'emitDecoratorMetadata' are enabled."), + _0_modifier_cannot_appear_on_a_type_parameter: diag(1273, DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_parameter_1273", "'{0}' modifier cannot appear on a type parameter"), + _0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias: diag(1274, DiagnosticCategory.Error, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274", "'{0}' modifier can only appear on a type parameter of a class, interface or type alias"), + accessor_modifier_can_only_appear_on_a_property_declaration: diag(1275, DiagnosticCategory.Error, "accessor_modifier_can_only_appear_on_a_property_declaration_1275", "'accessor' modifier can only appear on a property declaration."), + An_accessor_property_cannot_be_declared_optional: diag(1276, DiagnosticCategory.Error, "An_accessor_property_cannot_be_declared_optional_1276", "An 'accessor' property cannot be declared optional."), + with_statements_are_not_allowed_in_an_async_function_block: diag(1300, DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), + await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), + The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."), + Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), + The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), + Global_module_exports_may_only_appear_in_module_files: diag(1314, DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), + Global_module_exports_may_only_appear_in_declaration_files: diag(1315, DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), + Global_module_exports_may_only_appear_at_top_level: diag(1316, DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), + A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), + An_abstract_accessor_cannot_have_an_implementation: diag(1318, DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext: diag(1323, DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'."), + Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext: diag(1324, DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nod_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'."), + Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."), + This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, DiagnosticCategory.Error, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."), + String_literal_with_double_quotes_expected: diag(1327, DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), + Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), + _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), + A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), + A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), + A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), + unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), + unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), + unique_symbol_types_are_not_allowed_here: diag(1335, DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), + An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead: diag(1337, DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337", "An index signature parameter type cannot be a literal type or generic type. Consider using a mapped object type instead."), + infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), + Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), + Class_constructor_may_not_be_an_accessor: diag(1341, DiagnosticCategory.Error, "Class_constructor_may_not_be_an_accessor_1341", "Class constructor may not be an accessor."), + Type_arguments_cannot_be_used_here: diag(1342, DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext: diag(1343, DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'."), + A_label_is_not_allowed_here: diag(1344, DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), + An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."), + This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), + use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), + Non_simple_parameter_declared_here: diag(1348, DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), + use_strict_directive_used_here: diag(1349, DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), + An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), + A_bigint_literal_cannot_use_exponential_notation: diag(1352, DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), + A_bigint_literal_must_be_an_integer: diag(1353, DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), + readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), + A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), + Did_you_mean_to_mark_this_function_as_async: diag(1356, DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."), + Type_0_does_not_satisfy_the_expected_type_1: diag(1360, DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_expected_type_1_1360", "Type '{0}' does not satisfy the expected type '{1}'."), + _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type: diag(1361, DiagnosticCategory.Error, "_0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type_1361", "'{0}' cannot be used as a value because it was imported using 'import type'."), + _0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type: diag(1362, DiagnosticCategory.Error, "_0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type_1362", "'{0}' cannot be used as a value because it was exported using 'export type'."), + A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both: diag(1363, DiagnosticCategory.Error, "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363", "A type-only import can specify a default import or named bindings, but not both."), + Convert_to_type_only_export: diag(1364, DiagnosticCategory.Message, "Convert_to_type_only_export_1364", "Convert to type-only export"), + Convert_all_re_exported_types_to_type_only_exports: diag(1365, DiagnosticCategory.Message, "Convert_all_re_exported_types_to_type_only_exports_1365", "Convert all re-exported types to type-only exports"), + Split_into_two_separate_import_declarations: diag(1366, DiagnosticCategory.Message, "Split_into_two_separate_import_declarations_1366", "Split into two separate import declarations"), + Split_all_invalid_type_only_imports: diag(1367, DiagnosticCategory.Message, "Split_all_invalid_type_only_imports_1367", "Split all invalid type-only imports"), + Class_constructor_may_not_be_a_generator: diag(1368, DiagnosticCategory.Error, "Class_constructor_may_not_be_a_generator_1368", "Class constructor may not be a generator."), + Did_you_mean_0: diag(1369, DiagnosticCategory.Message, "Did_you_mean_0_1369", "Did you mean '{0}'?"), + This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error: diag(1371, DiagnosticCategory.Error, "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371", "This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'."), + Convert_to_type_only_import: diag(1373, DiagnosticCategory.Message, "Convert_to_type_only_import_1373", "Convert to type-only import"), + Convert_all_imports_not_used_as_a_value_to_type_only_imports: diag(1374, DiagnosticCategory.Message, "Convert_all_imports_not_used_as_a_value_to_type_only_imports_1374", "Convert all imports not used as a value to type-only imports"), + await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), + _0_was_imported_here: diag(1376, DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."), + _0_was_exported_here: diag(1377, DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."), + Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), + An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), + Unexpected_token_Did_you_mean_or_rbrace: diag(1381, DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"), + Unexpected_token_Did_you_mean_or_gt: diag(1382, DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `>`?"), + Only_named_exports_may_use_export_type: diag(1383, DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."), + Function_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1385, DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_a_union_type_1385", "Function type notation must be parenthesized when used in a union type."), + Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1386, DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386", "Constructor type notation must be parenthesized when used in a union type."), + Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."), + Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), + _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), + _0_is_not_allowed_as_a_parameter_name: diag(1390, DiagnosticCategory.Error, "_0_is_not_allowed_as_a_parameter_name_1390", "'{0}' is not allowed as a parameter name."), + An_import_alias_cannot_use_import_type: diag(1392, DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"), + Imported_via_0_from_file_1: diag(1393, DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"), + Imported_via_0_from_file_1_with_packageId_2: diag(1394, DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"), + Imported_via_0_from_file_1_to_import_importHelpers_as_specified_in_compilerOptions: diag(1395, DiagnosticCategory.Message, "Imported_via_0_from_file_1_to_import_importHelpers_as_specified_in_compilerOptions_1395", "Imported via {0} from file '{1}' to import 'importHelpers' as specified in compilerOptions"), + Imported_via_0_from_file_1_with_packageId_2_to_import_importHelpers_as_specified_in_compilerOptions: diag(1396, DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_to_import_importHelpers_as_specified_in_compilerOptions_1396", "Imported via {0} from file '{1}' with packageId '{2}' to import 'importHelpers' as specified in compilerOptions"), + Imported_via_0_from_file_1_to_import_jsx_and_jsxs_factory_functions: diag(1397, DiagnosticCategory.Message, "Imported_via_0_from_file_1_to_import_jsx_and_jsxs_factory_functions_1397", "Imported via {0} from file '{1}' to import 'jsx' and 'jsxs' factory functions"), + Imported_via_0_from_file_1_with_packageId_2_to_import_jsx_and_jsxs_factory_functions: diag(1398, DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_to_import_jsx_and_jsxs_factory_functions_1398", "Imported via {0} from file '{1}' with packageId '{2}' to import 'jsx' and 'jsxs' factory functions"), + File_is_included_via_import_here: diag(1399, DiagnosticCategory.Message, "File_is_included_via_import_here_1399", "File is included via import here."), + Referenced_via_0_from_file_1: diag(1400, DiagnosticCategory.Message, "Referenced_via_0_from_file_1_1400", "Referenced via '{0}' from file '{1}'"), + File_is_included_via_reference_here: diag(1401, DiagnosticCategory.Message, "File_is_included_via_reference_here_1401", "File is included via reference here."), + Type_library_referenced_via_0_from_file_1: diag(1402, DiagnosticCategory.Message, "Type_library_referenced_via_0_from_file_1_1402", "Type library referenced via '{0}' from file '{1}'"), + Type_library_referenced_via_0_from_file_1_with_packageId_2: diag(1403, DiagnosticCategory.Message, "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403", "Type library referenced via '{0}' from file '{1}' with packageId '{2}'"), + File_is_included_via_type_library_reference_here: diag(1404, DiagnosticCategory.Message, "File_is_included_via_type_library_reference_here_1404", "File is included via type library reference here."), + Library_referenced_via_0_from_file_1: diag(1405, DiagnosticCategory.Message, "Library_referenced_via_0_from_file_1_1405", "Library referenced via '{0}' from file '{1}'"), + File_is_included_via_library_reference_here: diag(1406, DiagnosticCategory.Message, "File_is_included_via_library_reference_here_1406", "File is included via library reference here."), + Matched_by_include_pattern_0_in_1: diag(1407, DiagnosticCategory.Message, "Matched_by_include_pattern_0_in_1_1407", "Matched by include pattern '{0}' in '{1}'"), + File_is_matched_by_include_pattern_specified_here: diag(1408, DiagnosticCategory.Message, "File_is_matched_by_include_pattern_specified_here_1408", "File is matched by include pattern specified here."), + Part_of_files_list_in_tsconfig_json: diag(1409, DiagnosticCategory.Message, "Part_of_files_list_in_tsconfig_json_1409", "Part of 'files' list in tsconfig.json"), + File_is_matched_by_files_list_specified_here: diag(1410, DiagnosticCategory.Message, "File_is_matched_by_files_list_specified_here_1410", "File is matched by 'files' list specified here."), + Output_from_referenced_project_0_included_because_1_specified: diag(1411, DiagnosticCategory.Message, "Output_from_referenced_project_0_included_because_1_specified_1411", "Output from referenced project '{0}' included because '{1}' specified"), + Output_from_referenced_project_0_included_because_module_is_specified_as_none: diag(1412, DiagnosticCategory.Message, "Output_from_referenced_project_0_included_because_module_is_specified_as_none_1412", "Output from referenced project '{0}' included because '--module' is specified as 'none'"), + File_is_output_from_referenced_project_specified_here: diag(1413, DiagnosticCategory.Message, "File_is_output_from_referenced_project_specified_here_1413", "File is output from referenced project specified here."), + Source_from_referenced_project_0_included_because_1_specified: diag(1414, DiagnosticCategory.Message, "Source_from_referenced_project_0_included_because_1_specified_1414", "Source from referenced project '{0}' included because '{1}' specified"), + Source_from_referenced_project_0_included_because_module_is_specified_as_none: diag(1415, DiagnosticCategory.Message, "Source_from_referenced_project_0_included_because_module_is_specified_as_none_1415", "Source from referenced project '{0}' included because '--module' is specified as 'none'"), + File_is_source_from_referenced_project_specified_here: diag(1416, DiagnosticCategory.Message, "File_is_source_from_referenced_project_specified_here_1416", "File is source from referenced project specified here."), + Entry_point_of_type_library_0_specified_in_compilerOptions: diag(1417, DiagnosticCategory.Message, "Entry_point_of_type_library_0_specified_in_compilerOptions_1417", "Entry point of type library '{0}' specified in compilerOptions"), + Entry_point_of_type_library_0_specified_in_compilerOptions_with_packageId_1: diag(1418, DiagnosticCategory.Message, "Entry_point_of_type_library_0_specified_in_compilerOptions_with_packageId_1_1418", "Entry point of type library '{0}' specified in compilerOptions with packageId '{1}'"), + File_is_entry_point_of_type_library_specified_here: diag(1419, DiagnosticCategory.Message, "File_is_entry_point_of_type_library_specified_here_1419", "File is entry point of type library specified here."), + Entry_point_for_implicit_type_library_0: diag(1420, DiagnosticCategory.Message, "Entry_point_for_implicit_type_library_0_1420", "Entry point for implicit type library '{0}'"), + Entry_point_for_implicit_type_library_0_with_packageId_1: diag(1421, DiagnosticCategory.Message, "Entry_point_for_implicit_type_library_0_with_packageId_1_1421", "Entry point for implicit type library '{0}' with packageId '{1}'"), + Library_0_specified_in_compilerOptions: diag(1422, DiagnosticCategory.Message, "Library_0_specified_in_compilerOptions_1422", "Library '{0}' specified in compilerOptions"), + File_is_library_specified_here: diag(1423, DiagnosticCategory.Message, "File_is_library_specified_here_1423", "File is library specified here."), + Default_library: diag(1424, DiagnosticCategory.Message, "Default_library_1424", "Default library"), + Default_library_for_target_0: diag(1425, DiagnosticCategory.Message, "Default_library_for_target_0_1425", "Default library for target '{0}'"), + File_is_default_library_for_target_specified_here: diag(1426, DiagnosticCategory.Message, "File_is_default_library_for_target_specified_here_1426", "File is default library for target specified here."), + Root_file_specified_for_compilation: diag(1427, DiagnosticCategory.Message, "Root_file_specified_for_compilation_1427", "Root file specified for compilation"), + File_is_output_of_project_reference_source_0: diag(1428, DiagnosticCategory.Message, "File_is_output_of_project_reference_source_0_1428", "File is output of project reference source '{0}'"), + File_redirects_to_file_0: diag(1429, DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), + The_file_is_in_the_program_because_Colon: diag(1430, DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), + for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Decorators_may_not_be_applied_to_this_parameters: diag(1433, DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), + Unexpected_keyword_or_identifier: diag(1434, DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."), + Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"), + Decorators_must_precede_the_name_and_all_keywords_of_property_declarations: diag(1436, DiagnosticCategory.Error, "Decorators_must_precede_the_name_and_all_keywords_of_property_declarations_1436", "Decorators must precede the name and all keywords of property declarations."), + Namespace_must_be_given_a_name: diag(1437, DiagnosticCategory.Error, "Namespace_must_be_given_a_name_1437", "Namespace must be given a name."), + Interface_must_be_given_a_name: diag(1438, DiagnosticCategory.Error, "Interface_must_be_given_a_name_1438", "Interface must be given a name."), + Type_alias_must_be_given_a_name: diag(1439, DiagnosticCategory.Error, "Type_alias_must_be_given_a_name_1439", "Type alias must be given a name."), + Variable_declaration_not_allowed_at_this_location: diag(1440, DiagnosticCategory.Error, "Variable_declaration_not_allowed_at_this_location_1440", "Variable declaration not allowed at this location."), + Cannot_start_a_function_call_in_a_type_annotation: diag(1441, DiagnosticCategory.Error, "Cannot_start_a_function_call_in_a_type_annotation_1441", "Cannot start a function call in a type annotation."), + Expected_for_property_initializer: diag(1442, DiagnosticCategory.Error, "Expected_for_property_initializer_1442", "Expected '=' for property initializer."), + Module_declaration_names_may_only_use_or_quoted_strings: diag(1443, DiagnosticCategory.Error, "Module_declaration_names_may_only_use_or_quoted_strings_1443", "Module declaration names may only use ' or \" quoted strings."), + _0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled: diag(1444, DiagnosticCategory.Error, "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444", "'{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled."), + _0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled: diag(1446, DiagnosticCategory.Error, "_0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveVa_1446", "'{0}' resolves to a type-only declaration and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled."), + _0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_isolatedModules_is_enabled: diag(1448, DiagnosticCategory.Error, "_0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_isol_1448", "'{0}' resolves to a type-only declaration and must be re-exported using a type-only re-export when 'isolatedModules' is enabled."), + Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."), + Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"), + Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"), + resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, DiagnosticCategory.Error, "resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`."), + resolution_mode_should_be_either_require_or_import: diag(1453, DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."), + resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."), + resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), + Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."), + Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"), + File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""), + File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""), + File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""), + File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"), + The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."), + Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."), + catch_or_finally_expected: diag(1472, DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."), + An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), + An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), + Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), + auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), + An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."), + Identifier_or_string_literal_expected: diag(1478, DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."), + The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."), + To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."), + To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."), + The_types_of_0_are_incompatible_between_these_types: diag(2200, DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."), + The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."), + This_type_parameter_might_need_an_extends_0_constraint: diag(2208, DiagnosticCategory.Error, "This_type_parameter_might_need_an_extends_0_constraint_2208", "This type parameter might need an `extends {0}` constraint."), + The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), + The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), + Add_extends_constraint: diag(2211, DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."), + Add_extends_constraint_to_all_type_parameters: diag(2212, DiagnosticCategory.Message, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"), + Duplicate_identifier_0: diag(2300, DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), + Static_members_cannot_reference_class_type_parameters: diag(2302, DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), + Circular_definition_of_import_alias_0: diag(2303, DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), + Cannot_find_name_0: diag(2304, DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), + Module_0_has_no_exported_member_1: diag(2305, DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), + File_0_is_not_a_module: diag(2306, DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), + Cannot_find_module_0_or_its_corresponding_type_declarations: diag(2307, DiagnosticCategory.Error, "Cannot_find_module_0_or_its_corresponding_type_declarations_2307", "Cannot find module '{0}' or its corresponding type declarations."), + Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), + Type_0_recursively_references_itself_as_a_base_type: diag(2310, DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), + Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function: diag(2311, DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function_2311", "Cannot find name '{0}'. Did you mean to write this in an async function?"), + An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), + Type_parameter_0_has_a_circular_constraint: diag(2313, DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), + Generic_type_0_requires_1_type_argument_s: diag(2314, DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), + Type_0_is_not_generic: diag(2315, DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), + Global_type_0_must_be_a_class_or_interface_type: diag(2316, DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), + Global_type_0_must_have_1_type_parameter_s: diag(2317, DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), + Cannot_find_global_type_0: diag(2318, DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), + Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), + Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), + Excessive_stack_depth_comparing_types_0_and_1: diag(2321, DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), + Type_0_is_not_assignable_to_type_1: diag(2322, DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), + Cannot_redeclare_exported_variable_0: diag(2323, DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), + Property_0_is_missing_in_type_1: diag(2324, DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), + Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), + Types_of_property_0_are_incompatible: diag(2326, DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), + Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), + Types_of_parameters_0_and_1_are_incompatible: diag(2328, DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), + Index_signature_for_type_0_is_missing_in_type_1: diag(2329, DiagnosticCategory.Error, "Index_signature_for_type_0_is_missing_in_type_1_2329", "Index signature for type '{0}' is missing in type '{1}'."), + _0_and_1_index_signatures_are_incompatible: diag(2330, DiagnosticCategory.Error, "_0_and_1_index_signatures_are_incompatible_2330", "'{0}' and '{1}' index signatures are incompatible."), + this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), + this_cannot_be_referenced_in_current_location: diag(2332, DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), + this_cannot_be_referenced_in_constructor_arguments: diag(2333, DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), + this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), + super_can_only_be_referenced_in_a_derived_class: diag(2335, DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), + super_cannot_be_referenced_in_constructor_arguments: diag(2336, DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: diag(2338, DiagnosticCategory.Error, "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class."), + Property_0_does_not_exist_on_type_1: diag(2339, DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."), + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), + Property_0_is_private_and_only_accessible_within_class_1: diag(2341, DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), + Type_0_does_not_satisfy_the_constraint_1: diag(2344, DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), + Call_target_does_not_contain_any_signatures: diag(2346, DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), + Untyped_function_calls_may_not_accept_type_arguments: diag(2347, DiagnosticCategory.Error, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."), + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, DiagnosticCategory.Error, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"), + This_expression_is_not_callable: diag(2349, DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."), + Only_a_void_function_can_be_called_with_the_new_keyword: diag(2350, DiagnosticCategory.Error, "Only_a_void_function_can_be_called_with_the_new_keyword_2350", "Only a void function can be called with the 'new' keyword."), + This_expression_is_not_constructable: diag(2351, DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."), + Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, DiagnosticCategory.Error, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."), + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), + Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), + Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap: diag(2367, DiagnosticCategory.Error, "This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap_2367", "This comparison appears to be unintentional because the types '{0}' and '{1}' have no overlap."), + Type_parameter_name_cannot_be_0: diag(2368, DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), + A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), + A_rest_parameter_must_be_of_an_array_type: diag(2370, DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."), + Parameter_0_cannot_reference_itself: diag(2372, DiagnosticCategory.Error, "Parameter_0_cannot_reference_itself_2372", "Parameter '{0}' cannot reference itself."), + Parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, DiagnosticCategory.Error, "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Parameter '{0}' cannot reference identifier '{1}' declared after it."), + Duplicate_index_signature_for_type_0: diag(2374, DiagnosticCategory.Error, "Duplicate_index_signature_for_type_0_2374", "Duplicate index signature for type '{0}'."), + Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2375, DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2375", "Type '{0}' is not assignable to type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."), + A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_2376", "A 'super' call must be the first statement in the constructor to refer to 'super' or 'this' when a derived class contains initialized properties, parameter properties, or private identifiers."), + Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), + A_get_accessor_must_return_a_value: diag(2378, DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2379, DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_tr_2379", "Argument of type '{0}' is not assignable to parameter of type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."), + The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type: diag(2380, DiagnosticCategory.Error, "The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type_2380", "The return type of a 'get' accessor must be assignable to its 'set' accessor type"), + Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), + Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."), + Overload_signatures_must_all_be_public_private_or_protected: diag(2385, DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."), + Overload_signatures_must_all_be_optional_or_required: diag(2386, DiagnosticCategory.Error, "Overload_signatures_must_all_be_optional_or_required_2386", "Overload signatures must all be optional or required."), + Function_overload_must_be_static: diag(2387, DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."), + Function_overload_must_not_be_static: diag(2388, DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."), + Function_implementation_name_must_be_0: diag(2389, DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."), + Constructor_implementation_is_missing: diag(2390, DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."), + Function_implementation_is_missing_or_not_immediately_following_the_declaration: diag(2391, DiagnosticCategory.Error, "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", "Function implementation is missing or not immediately following the declaration."), + Multiple_constructor_implementations_are_not_allowed: diag(2392, DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."), + Duplicate_function_implementation: diag(2393, DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."), + This_overload_signature_is_not_compatible_with_its_implementation_signature: diag(2394, DiagnosticCategory.Error, "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394", "This overload signature is not compatible with its implementation signature."), + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: diag(2395, DiagnosticCategory.Error, "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", "Individual declarations in merged declaration '{0}' must be all exported or all local."), + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: diag(2396, DiagnosticCategory.Error, "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters."), + Declaration_name_conflicts_with_built_in_global_identifier_0: diag(2397, DiagnosticCategory.Error, "Declaration_name_conflicts_with_built_in_global_identifier_0_2397", "Declaration name conflicts with built-in global identifier '{0}'."), + constructor_cannot_be_used_as_a_parameter_property_name: diag(2398, DiagnosticCategory.Error, "constructor_cannot_be_used_as_a_parameter_property_name_2398", "'constructor' cannot be used as a parameter property name."), + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."), + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."), + A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2401, DiagnosticCategory.Error, "A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_in_2401", "A 'super' call must be a root-level statement within a constructor of a derived class that contains initialized properties, parameter properties, or private identifiers."), + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."), + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."), + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."), + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: diag(2405, DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'."), + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: diag(2406, DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", "The left-hand side of a 'for...in' statement must be a variable or a property access."), + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0: diag(2407, DiagnosticCategory.Error, "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_2407", "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '{0}'."), + Setters_cannot_return_a_value: diag(2408, DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."), + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: diag(2409, DiagnosticCategory.Error, "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", "Return type of constructor signature must be assignable to the instance type of the class."), + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: diag(2410, DiagnosticCategory.Error, "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'."), + Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target: diag(2412, DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2412", "Type '{0}' is not assignable to type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target."), + Property_0_of_type_1_is_not_assignable_to_2_index_type_3: diag(2411, DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_2_index_type_3_2411", "Property '{0}' of type '{1}' is not assignable to '{2}' index type '{3}'."), + _0_index_type_1_is_not_assignable_to_2_index_type_3: diag(2413, DiagnosticCategory.Error, "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413", "'{0}' index type '{1}' is not assignable to '{2}' index type '{3}'."), + Class_name_cannot_be_0: diag(2414, DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."), + Class_0_incorrectly_extends_base_class_1: diag(2415, DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), + Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), + Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), + Types_of_construct_signatures_are_incompatible: diag(2419, DiagnosticCategory.Error, "Types_of_construct_signatures_are_incompatible_2419", "Types of construct signatures are incompatible."), + Class_0_incorrectly_implements_interface_1: diag(2420, DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), + A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."), + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."), + Interface_name_cannot_be_0: diag(2427, DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."), + All_declarations_of_0_must_have_identical_type_parameters: diag(2428, DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_type_parameters_2428", "All declarations of '{0}' must have identical type parameters."), + Interface_0_incorrectly_extends_interface_1: diag(2430, DiagnosticCategory.Error, "Interface_0_incorrectly_extends_interface_1_2430", "Interface '{0}' incorrectly extends interface '{1}'."), + Enum_name_cannot_be_0: diag(2431, DiagnosticCategory.Error, "Enum_name_cannot_be_0_2431", "Enum name cannot be '{0}'."), + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: diag(2432, DiagnosticCategory.Error, "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element."), + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: diag(2433, DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", "A namespace declaration cannot be in a different file from a class or function with which it is merged."), + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: diag(2434, DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", "A namespace declaration cannot be located prior to a class or function with which it is merged."), + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: diag(2435, DiagnosticCategory.Error, "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", "Ambient modules cannot be nested in other modules or namespaces."), + Ambient_module_declaration_cannot_specify_relative_module_name: diag(2436, DiagnosticCategory.Error, "Ambient_module_declaration_cannot_specify_relative_module_name_2436", "Ambient module declaration cannot specify relative module name."), + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: diag(2437, DiagnosticCategory.Error, "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", "Module '{0}' is hidden by a local declaration with the same name."), + Import_name_cannot_be_0: diag(2438, DiagnosticCategory.Error, "Import_name_cannot_be_0_2438", "Import name cannot be '{0}'."), + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: diag(2439, DiagnosticCategory.Error, "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", "Import or export declaration in an ambient module declaration cannot reference module through relative module name."), + Import_declaration_conflicts_with_local_declaration_of_0: diag(2440, DiagnosticCategory.Error, "Import_declaration_conflicts_with_local_declaration_of_0_2440", "Import declaration conflicts with local declaration of '{0}'."), + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: diag(2441, DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module."), + Types_have_separate_declarations_of_a_private_property_0: diag(2442, DiagnosticCategory.Error, "Types_have_separate_declarations_of_a_private_property_0_2442", "Types have separate declarations of a private property '{0}'."), + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."), + Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."), + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."), + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2: diag(2446, DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_cl_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'. This is an instance of class '{2}'."), + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."), + Block_scoped_variable_0_used_before_its_declaration: diag(2448, DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."), + Class_0_used_before_its_declaration: diag(2449, DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."), + Enum_0_used_before_its_declaration: diag(2450, DiagnosticCategory.Error, "Enum_0_used_before_its_declaration_2450", "Enum '{0}' used before its declaration."), + Cannot_redeclare_block_scoped_variable_0: diag(2451, DiagnosticCategory.Error, "Cannot_redeclare_block_scoped_variable_0_2451", "Cannot redeclare block-scoped variable '{0}'."), + An_enum_member_cannot_have_a_numeric_name: diag(2452, DiagnosticCategory.Error, "An_enum_member_cannot_have_a_numeric_name_2452", "An enum member cannot have a numeric name."), + Variable_0_is_used_before_being_assigned: diag(2454, DiagnosticCategory.Error, "Variable_0_is_used_before_being_assigned_2454", "Variable '{0}' is used before being assigned."), + Type_alias_0_circularly_references_itself: diag(2456, DiagnosticCategory.Error, "Type_alias_0_circularly_references_itself_2456", "Type alias '{0}' circularly references itself."), + Type_alias_name_cannot_be_0: diag(2457, DiagnosticCategory.Error, "Type_alias_name_cannot_be_0_2457", "Type alias name cannot be '{0}'."), + An_AMD_module_cannot_have_multiple_name_assignments: diag(2458, DiagnosticCategory.Error, "An_AMD_module_cannot_have_multiple_name_assignments_2458", "An AMD module cannot have multiple name assignments."), + Module_0_declares_1_locally_but_it_is_not_exported: diag(2459, DiagnosticCategory.Error, "Module_0_declares_1_locally_but_it_is_not_exported_2459", "Module '{0}' declares '{1}' locally, but it is not exported."), + Module_0_declares_1_locally_but_it_is_exported_as_2: diag(2460, DiagnosticCategory.Error, "Module_0_declares_1_locally_but_it_is_exported_as_2_2460", "Module '{0}' declares '{1}' locally, but it is exported as '{2}'."), + Type_0_is_not_an_array_type: diag(2461, DiagnosticCategory.Error, "Type_0_is_not_an_array_type_2461", "Type '{0}' is not an array type."), + A_rest_element_must_be_last_in_a_destructuring_pattern: diag(2462, DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", "A rest element must be last in a destructuring pattern."), + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: diag(2463, DiagnosticCategory.Error, "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", "A binding pattern parameter cannot be optional in an implementation signature."), + A_computed_property_name_must_be_of_type_string_number_symbol_or_any: diag(2464, DiagnosticCategory.Error, "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", "A computed property name must be of type 'string', 'number', 'symbol', or 'any'."), + this_cannot_be_referenced_in_a_computed_property_name: diag(2465, DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_computed_property_name_2465", "'this' cannot be referenced in a computed property name."), + super_cannot_be_referenced_in_a_computed_property_name: diag(2466, DiagnosticCategory.Error, "super_cannot_be_referenced_in_a_computed_property_name_2466", "'super' cannot be referenced in a computed property name."), + A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: diag(2467, DiagnosticCategory.Error, "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467", "A computed property name cannot reference a type parameter from its containing type."), + Cannot_find_global_value_0: diag(2468, DiagnosticCategory.Error, "Cannot_find_global_value_0_2468", "Cannot find global value '{0}'."), + The_0_operator_cannot_be_applied_to_type_symbol: diag(2469, DiagnosticCategory.Error, "The_0_operator_cannot_be_applied_to_type_symbol_2469", "The '{0}' operator cannot be applied to type 'symbol'."), + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: diag(2472, DiagnosticCategory.Error, "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472", "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher."), + Enum_declarations_must_all_be_const_or_non_const: diag(2473, DiagnosticCategory.Error, "Enum_declarations_must_all_be_const_or_non_const_2473", "Enum declarations must all be const or non-const."), + const_enum_member_initializers_must_be_constant_expressions: diag(2474, DiagnosticCategory.Error, "const_enum_member_initializers_must_be_constant_expressions_2474", "const enum member initializers must be constant expressions."), + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query: diag(2475, DiagnosticCategory.Error, "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475", "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query."), + A_const_enum_member_can_only_be_accessed_using_a_string_literal: diag(2476, DiagnosticCategory.Error, "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476", "A const enum member can only be accessed using a string literal."), + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: diag(2477, DiagnosticCategory.Error, "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477", "'const' enum member initializer was evaluated to a non-finite value."), + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: diag(2478, DiagnosticCategory.Error, "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478", "'const' enum member initializer was evaluated to disallowed value 'NaN'."), + let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: diag(2480, DiagnosticCategory.Error, "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", "'let' is not allowed to be used as a name in 'let' or 'const' declarations."), + Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: diag(2481, DiagnosticCategory.Error, "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'."), + The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: diag(2483, DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", "The left-hand side of a 'for...of' statement cannot use a type annotation."), + Export_declaration_conflicts_with_exported_declaration_of_0: diag(2484, DiagnosticCategory.Error, "Export_declaration_conflicts_with_exported_declaration_of_0_2484", "Export declaration conflicts with exported declaration of '{0}'."), + The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: diag(2487, DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", "The left-hand side of a 'for...of' statement must be a variable or a property access."), + Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2488, DiagnosticCategory.Error, "Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", "Type '{0}' must have a '[Symbol.iterator]()' method that returns an iterator."), + An_iterator_must_have_a_next_method: diag(2489, DiagnosticCategory.Error, "An_iterator_must_have_a_next_method_2489", "An iterator must have a 'next()' method."), + The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property: diag(2490, DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property_2490", "The type returned by the '{0}()' method of an iterator must have a 'value' property."), + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: diag(2491, DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", "The left-hand side of a 'for...in' statement cannot be a destructuring pattern."), + Cannot_redeclare_identifier_0_in_catch_clause: diag(2492, DiagnosticCategory.Error, "Cannot_redeclare_identifier_0_in_catch_clause_2492", "Cannot redeclare identifier '{0}' in catch clause."), + Tuple_type_0_of_length_1_has_no_element_at_index_2: diag(2493, DiagnosticCategory.Error, "Tuple_type_0_of_length_1_has_no_element_at_index_2_2493", "Tuple type '{0}' of length '{1}' has no element at index '{2}'."), + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: diag(2494, DiagnosticCategory.Error, "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher."), + Type_0_is_not_an_array_type_or_a_string_type: diag(2495, DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_2495", "Type '{0}' is not an array type or a string type."), + The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: diag(2496, DiagnosticCategory.Error, "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_stand_2496", "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression."), + This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export: diag(2497, DiagnosticCategory.Error, "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497", "This module can only be referenced with ECMAScript imports/exports by turning on the '{0}' flag and referencing its default export."), + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: diag(2498, DiagnosticCategory.Error, "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498", "Module '{0}' uses 'export =' and cannot be used with 'export *'."), + An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: diag(2499, DiagnosticCategory.Error, "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499", "An interface can only extend an identifier/qualified-name with optional type arguments."), + A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: diag(2500, DiagnosticCategory.Error, "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500", "A class can only implement an identifier/qualified-name with optional type arguments."), + A_rest_element_cannot_contain_a_binding_pattern: diag(2501, DiagnosticCategory.Error, "A_rest_element_cannot_contain_a_binding_pattern_2501", "A rest element cannot contain a binding pattern."), + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: diag(2502, DiagnosticCategory.Error, "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", "'{0}' is referenced directly or indirectly in its own type annotation."), + Cannot_find_namespace_0: diag(2503, DiagnosticCategory.Error, "Cannot_find_namespace_0_2503", "Cannot find namespace '{0}'."), + Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: diag(2504, DiagnosticCategory.Error, "Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504", "Type '{0}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator."), + A_generator_cannot_have_a_void_type_annotation: diag(2505, DiagnosticCategory.Error, "A_generator_cannot_have_a_void_type_annotation_2505", "A generator cannot have a 'void' type annotation."), + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: diag(2506, DiagnosticCategory.Error, "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", "'{0}' is referenced directly or indirectly in its own base expression."), + Type_0_is_not_a_constructor_function_type: diag(2507, DiagnosticCategory.Error, "Type_0_is_not_a_constructor_function_type_2507", "Type '{0}' is not a constructor function type."), + No_base_constructor_has_the_specified_number_of_type_arguments: diag(2508, DiagnosticCategory.Error, "No_base_constructor_has_the_specified_number_of_type_arguments_2508", "No base constructor has the specified number of type arguments."), + Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2509, DiagnosticCategory.Error, "Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_2509", "Base constructor return type '{0}' is not an object type or intersection of object types with statically known members."), + Base_constructors_must_all_have_the_same_return_type: diag(2510, DiagnosticCategory.Error, "Base_constructors_must_all_have_the_same_return_type_2510", "Base constructors must all have the same return type."), + Cannot_create_an_instance_of_an_abstract_class: diag(2511, DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."), + Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."), + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."), + A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."), + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."), + All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."), + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."), + A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: diag(2518, DiagnosticCategory.Error, "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", "A 'this'-based type guard is not compatible with a parameter-based type guard."), + An_async_iterator_must_have_a_next_method: diag(2519, DiagnosticCategory.Error, "An_async_iterator_must_have_a_next_method_2519", "An async iterator must have a 'next()' method."), + Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: diag(2520, DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions."), + The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: diag(2522, DiagnosticCategory.Error, "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method."), + yield_expressions_cannot_be_used_in_a_parameter_initializer: diag(2523, DiagnosticCategory.Error, "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", "'yield' expressions cannot be used in a parameter initializer."), + await_expressions_cannot_be_used_in_a_parameter_initializer: diag(2524, DiagnosticCategory.Error, "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", "'await' expressions cannot be used in a parameter initializer."), + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: diag(2525, DiagnosticCategory.Error, "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", "Initializer provides no value for this binding element and the binding element has no default value."), + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: diag(2526, DiagnosticCategory.Error, "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", "A 'this' type is available only in a non-static member of a class or interface."), + The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary: diag(2527, DiagnosticCategory.Error, "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527", "The inferred type of '{0}' references an inaccessible '{1}' type. A type annotation is necessary."), + A_module_cannot_have_multiple_default_exports: diag(2528, DiagnosticCategory.Error, "A_module_cannot_have_multiple_default_exports_2528", "A module cannot have multiple default exports."), + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: diag(2529, DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529", "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions."), + Property_0_is_incompatible_with_index_signature: diag(2530, DiagnosticCategory.Error, "Property_0_is_incompatible_with_index_signature_2530", "Property '{0}' is incompatible with index signature."), + Object_is_possibly_null: diag(2531, DiagnosticCategory.Error, "Object_is_possibly_null_2531", "Object is possibly 'null'."), + Object_is_possibly_undefined: diag(2532, DiagnosticCategory.Error, "Object_is_possibly_undefined_2532", "Object is possibly 'undefined'."), + Object_is_possibly_null_or_undefined: diag(2533, DiagnosticCategory.Error, "Object_is_possibly_null_or_undefined_2533", "Object is possibly 'null' or 'undefined'."), + A_function_returning_never_cannot_have_a_reachable_end_point: diag(2534, DiagnosticCategory.Error, "A_function_returning_never_cannot_have_a_reachable_end_point_2534", "A function returning 'never' cannot have a reachable end point."), + Type_0_cannot_be_used_to_index_type_1: diag(2536, DiagnosticCategory.Error, "Type_0_cannot_be_used_to_index_type_1_2536", "Type '{0}' cannot be used to index type '{1}'."), + Type_0_has_no_matching_index_signature_for_type_1: diag(2537, DiagnosticCategory.Error, "Type_0_has_no_matching_index_signature_for_type_1_2537", "Type '{0}' has no matching index signature for type '{1}'."), + Type_0_cannot_be_used_as_an_index_type: diag(2538, DiagnosticCategory.Error, "Type_0_cannot_be_used_as_an_index_type_2538", "Type '{0}' cannot be used as an index type."), + Cannot_assign_to_0_because_it_is_not_a_variable: diag(2539, DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_not_a_variable_2539", "Cannot assign to '{0}' because it is not a variable."), + Cannot_assign_to_0_because_it_is_a_read_only_property: diag(2540, DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_read_only_property_2540", "Cannot assign to '{0}' because it is a read-only property."), + Index_signature_in_type_0_only_permits_reading: diag(2542, DiagnosticCategory.Error, "Index_signature_in_type_0_only_permits_reading_2542", "Index signature in type '{0}' only permits reading."), + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: diag(2543, DiagnosticCategory.Error, "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference."), + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: diag(2544, DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference."), + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: diag(2545, DiagnosticCategory.Error, "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", "A mixin class must have a constructor with a single rest parameter of type 'any[]'."), + The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), + Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), + Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), + Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{2}' or later."), + Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"), + Cannot_find_name_0_Did_you_mean_1: diag(2552, DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"), + Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."), + Expected_0_arguments_but_got_1: diag(2554, DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."), + Expected_at_least_0_arguments_but_got_1: diag(2555, DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."), + A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter: diag(2556, DiagnosticCategory.Error, "A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter_2556", "A spread argument must either have a tuple type or be passed to a rest parameter."), + Expected_0_type_arguments_but_got_1: diag(2558, DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), + Type_0_has_no_properties_in_common_with_type_1: diag(2559, DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), + Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), + Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: diag(2561, DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561", "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2562, DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2562", "Base class expressions cannot reference class type parameters."), + The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: diag(2563, DiagnosticCategory.Error, "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563", "The containing function or module body is too large for control flow analysis."), + Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: diag(2564, DiagnosticCategory.Error, "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564", "Property '{0}' has no initializer and is not definitely assigned in the constructor."), + Property_0_is_used_before_being_assigned: diag(2565, DiagnosticCategory.Error, "Property_0_is_used_before_being_assigned_2565", "Property '{0}' is used before being assigned."), + A_rest_element_cannot_have_a_property_name: diag(2566, DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."), + Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."), + Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"), + Could_not_find_name_0_Did_you_mean_1: diag(2570, DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"), + Object_is_of_type_unknown: diag(2571, DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), + A_rest_element_type_must_be_an_array_type: diag(2574, DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), + No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), + Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead: diag(2576, DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576", "Property '{0}' does not exist on type '{1}'. Did you mean to access the static member '{2}' instead?"), + Return_type_annotation_circularly_references_itself: diag(2577, DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."), + Unused_ts_expect_error_directive: diag(2578, DiagnosticCategory.Error, "Unused_ts_expect_error_directive_2578", "Unused '@ts-expect-error' directive."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha: diag(2582, DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{1}' or later."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'."), + _0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2585, DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{0}' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later."), + Cannot_assign_to_0_because_it_is_a_constant: diag(2588, DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."), + Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."), + Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig."), + This_module_is_declared_with_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, DiagnosticCategory.Error, "This_module_is_declared_with_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag_2594", "This module is declared with 'export =', and can only be used with a default import when using the '{0}' flag."), + _0_can_only_be_imported_by_using_a_default_import: diag(2595, DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), + _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), + _0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import: diag(2597, DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import_2597", "'{0}' can only be imported by using a 'require' call or by using a default import."), + _0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2598, DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using__2598", "'{0}' can only be imported by using a 'require' call or by turning on the 'esModuleInterop' flag and using a default import."), + JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), + Property_0_in_type_1_is_not_assignable_to_type_2: diag(2603, DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_type_2_2603", "Property '{0}' in type '{1}' is not assignable to type '{2}'."), + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: diag(2604, DiagnosticCategory.Error, "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", "JSX element type '{0}' does not have any construct or call signatures."), + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: diag(2606, DiagnosticCategory.Error, "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", "Property '{0}' of JSX spread attribute is not assignable to target property."), + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), + The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), + JSX_spread_child_must_be_an_array_type: diag(2609, DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + _0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property: diag(2610, DiagnosticCategory.Error, "_0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property_2610", "'{0}' is defined as an accessor in class '{1}', but is overridden here in '{2}' as an instance property."), + _0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor: diag(2611, DiagnosticCategory.Error, "_0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor_2611", "'{0}' is defined as a property in class '{1}', but is overridden here in '{2}' as an accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(2613, DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(2614, DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), + Type_of_property_0_circularly_references_itself_in_mapped_type_1: diag(2615, DiagnosticCategory.Error, "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615", "Type of property '{0}' circularly references itself in mapped type '{1}'."), + _0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import: diag(2616, DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import_2616", "'{0}' can only be imported by using 'import {1} = require({2})' or a default import."), + _0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2617, DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_us_2617", "'{0}' can only be imported by using 'import {1} = require({2})' or by turning on the 'esModuleInterop' flag and using a default import."), + Source_has_0_element_s_but_target_requires_1: diag(2618, DiagnosticCategory.Error, "Source_has_0_element_s_but_target_requires_1_2618", "Source has {0} element(s) but target requires {1}."), + Source_has_0_element_s_but_target_allows_only_1: diag(2619, DiagnosticCategory.Error, "Source_has_0_element_s_but_target_allows_only_1_2619", "Source has {0} element(s) but target allows only {1}."), + Target_requires_0_element_s_but_source_may_have_fewer: diag(2620, DiagnosticCategory.Error, "Target_requires_0_element_s_but_source_may_have_fewer_2620", "Target requires {0} element(s) but source may have fewer."), + Target_allows_only_0_element_s_but_source_may_have_more: diag(2621, DiagnosticCategory.Error, "Target_allows_only_0_element_s_but_source_may_have_more_2621", "Target allows only {0} element(s) but source may have more."), + Source_provides_no_match_for_required_element_at_position_0_in_target: diag(2623, DiagnosticCategory.Error, "Source_provides_no_match_for_required_element_at_position_0_in_target_2623", "Source provides no match for required element at position {0} in target."), + Source_provides_no_match_for_variadic_element_at_position_0_in_target: diag(2624, DiagnosticCategory.Error, "Source_provides_no_match_for_variadic_element_at_position_0_in_target_2624", "Source provides no match for variadic element at position {0} in target."), + Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target: diag(2625, DiagnosticCategory.Error, "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625", "Variadic element at position {0} in source does not match element at position {1} in target."), + Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target: diag(2626, DiagnosticCategory.Error, "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626", "Type at position {0} in source is not compatible with type at position {1} in target."), + Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target: diag(2627, DiagnosticCategory.Error, "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627", "Type at positions {0} through {1} in source is not compatible with type at position {2} in target."), + Cannot_assign_to_0_because_it_is_an_enum: diag(2628, DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_enum_2628", "Cannot assign to '{0}' because it is an enum."), + Cannot_assign_to_0_because_it_is_a_class: diag(2629, DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_class_2629", "Cannot assign to '{0}' because it is a class."), + Cannot_assign_to_0_because_it_is_a_function: diag(2630, DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_function_2630", "Cannot assign to '{0}' because it is a function."), + Cannot_assign_to_0_because_it_is_a_namespace: diag(2631, DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_namespace_2631", "Cannot assign to '{0}' because it is a namespace."), + Cannot_assign_to_0_because_it_is_an_import: diag(2632, DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."), + JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"), + _0_index_signatures_are_incompatible: diag(2634, DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."), + Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."), + Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."), + Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."), + Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operator: diag(2638, DiagnosticCategory.Error, "Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operato_2638", "Type '{0}' may represent a primitive value, which is not permitted as the right operand of the 'in' operator."), + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: diag(2653, DiagnosticCategory.Error, "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'."), + JSX_expressions_must_have_one_parent_element: diag(2657, DiagnosticCategory.Error, "JSX_expressions_must_have_one_parent_element_2657", "JSX expressions must have one parent element."), + Type_0_provides_no_match_for_the_signature_1: diag(2658, DiagnosticCategory.Error, "Type_0_provides_no_match_for_the_signature_1_2658", "Type '{0}' provides no match for the signature '{1}'."), + super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: diag(2659, DiagnosticCategory.Error, "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher."), + super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: diag(2660, DiagnosticCategory.Error, "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", "'super' can only be referenced in members of derived classes or object literal expressions."), + Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: diag(2661, DiagnosticCategory.Error, "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661", "Cannot export '{0}'. Only local declarations can be exported from a module."), + Cannot_find_name_0_Did_you_mean_the_static_member_1_0: diag(2662, DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?"), + Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: diag(2663, DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?"), + Invalid_module_name_in_augmentation_module_0_cannot_be_found: diag(2664, DiagnosticCategory.Error, "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", "Invalid module name in augmentation, module '{0}' cannot be found."), + Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: diag(2665, DiagnosticCategory.Error, "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665", "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented."), + Exports_and_export_assignments_are_not_permitted_in_module_augmentations: diag(2666, DiagnosticCategory.Error, "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", "Exports and export assignments are not permitted in module augmentations."), + Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: diag(2667, DiagnosticCategory.Error, "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module."), + export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: diag(2668, DiagnosticCategory.Error, "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible."), + Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: diag(2669, DiagnosticCategory.Error, "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations."), + Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: diag(2670, DiagnosticCategory.Error, "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context."), + Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: diag(2671, DiagnosticCategory.Error, "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671", "Cannot augment module '{0}' because it resolves to a non-module entity."), + Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: diag(2672, DiagnosticCategory.Error, "Cannot_assign_a_0_constructor_type_to_a_1_constructor_type_2672", "Cannot assign a '{0}' constructor type to a '{1}' constructor type."), + Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: diag(2673, DiagnosticCategory.Error, "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673", "Constructor of class '{0}' is private and only accessible within the class declaration."), + Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: diag(2674, DiagnosticCategory.Error, "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674", "Constructor of class '{0}' is protected and only accessible within the class declaration."), + Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: diag(2675, DiagnosticCategory.Error, "Cannot_extend_a_class_0_Class_constructor_is_marked_as_private_2675", "Cannot extend a class '{0}'. Class constructor is marked as private."), + Accessors_must_both_be_abstract_or_non_abstract: diag(2676, DiagnosticCategory.Error, "Accessors_must_both_be_abstract_or_non_abstract_2676", "Accessors must both be abstract or non-abstract."), + A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type: diag(2677, DiagnosticCategory.Error, "A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type_2677", "A type predicate's type must be assignable to its parameter's type."), + Type_0_is_not_comparable_to_type_1: diag(2678, DiagnosticCategory.Error, "Type_0_is_not_comparable_to_type_1_2678", "Type '{0}' is not comparable to type '{1}'."), + A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: diag(2679, DiagnosticCategory.Error, "A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void_2679", "A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'."), + A_0_parameter_must_be_the_first_parameter: diag(2680, DiagnosticCategory.Error, "A_0_parameter_must_be_the_first_parameter_2680", "A '{0}' parameter must be the first parameter."), + A_constructor_cannot_have_a_this_parameter: diag(2681, DiagnosticCategory.Error, "A_constructor_cannot_have_a_this_parameter_2681", "A constructor cannot have a 'this' parameter."), + this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: diag(2683, DiagnosticCategory.Error, "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", "'this' implicitly has type 'any' because it does not have a type annotation."), + The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: diag(2684, DiagnosticCategory.Error, "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'."), + The_this_types_of_each_signature_are_incompatible: diag(2685, DiagnosticCategory.Error, "The_this_types_of_each_signature_are_incompatible_2685", "The 'this' types of each signature are incompatible."), + _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: diag(2686, DiagnosticCategory.Error, "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686", "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead."), + All_declarations_of_0_must_have_identical_modifiers: diag(2687, DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_modifiers_2687", "All declarations of '{0}' must have identical modifiers."), + Cannot_find_type_definition_file_for_0: diag(2688, DiagnosticCategory.Error, "Cannot_find_type_definition_file_for_0_2688", "Cannot find type definition file for '{0}'."), + Cannot_extend_an_interface_0_Did_you_mean_implements: diag(2689, DiagnosticCategory.Error, "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", "Cannot extend an interface '{0}'. Did you mean 'implements'?"), + _0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0: diag(2690, DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0_2690", "'{0}' only refers to a type, but is being used as a value here. Did you mean to use '{1} in {0}'?"), + An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: diag(2691, DiagnosticCategory.Error, "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead."), + _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."), + _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."), + Namespace_0_has_no_exported_member_1: diag(2694, DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."), + Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", /*reportsUnnecessary*/ true), + The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"), + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), + Spread_types_may_only_be_created_from_object_types: diag(2698, DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."), + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."), + Rest_types_may_only_be_created_from_object_types: diag(2700, DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."), + The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: diag(2701, DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", "The target of an object rest assignment must be a variable or a property access."), + _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."), + The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a 'delete' operator must be a property reference."), + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a 'delete' operator cannot be a read-only property."), + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2705, DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), + Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."), + Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."), + Cannot_use_namespace_0_as_a_value: diag(2708, DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."), + Cannot_use_namespace_0_as_a_type: diag(2709, DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."), + _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."), + A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), + A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), + Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: diag(2713, DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?"), + The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), + Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."), + Type_parameter_0_has_a_circular_default: diag(2716, DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_default_2716", "Type parameter '{0}' has a circular default."), + Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2: diag(2717, DiagnosticCategory.Error, "Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_t_2717", "Subsequent property declarations must have the same type. Property '{0}' must be of type '{1}', but here has type '{2}'."), + Duplicate_property_0: diag(2718, DiagnosticCategory.Error, "Duplicate_property_0_2718", "Duplicate property '{0}'."), + Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: diag(2719, DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_2719", "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated."), + Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass: diag(2720, DiagnosticCategory.Error, "Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclas_2720", "Class '{0}' incorrectly implements class '{1}'. Did you mean to extend '{1}' and inherit its members as a subclass?"), + Cannot_invoke_an_object_which_is_possibly_null: diag(2721, DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_2721", "Cannot invoke an object which is possibly 'null'."), + Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."), + Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."), + _0_has_no_exported_member_named_1_Did_you_mean_2: diag(2724, DiagnosticCategory.Error, "_0_has_no_exported_member_named_1_Did_you_mean_2_2724", "'{0}' has no exported member named '{1}'. Did you mean '{2}'?"), + Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), + Cannot_find_lib_definition_for_0: diag(2726, DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), + Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_is_declared_here: diag(2728, DiagnosticCategory.Message, "_0_is_declared_here_2728", "'{0}' is declared here."), + Property_0_is_used_before_its_initialization: diag(2729, DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), + An_arrow_function_cannot_have_a_this_parameter: diag(2730, DiagnosticCategory.Error, "An_arrow_function_cannot_have_a_this_parameter_2730", "An arrow function cannot have a 'this' parameter."), + Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."), + Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension."), + Property_0_was_also_declared_here: diag(2733, DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."), + Are_you_missing_a_semicolon: diag(2734, DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"), + Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"), + Operator_0_cannot_be_applied_to_type_1: diag(2736, DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."), + BigInt_literals_are_not_available_when_targeting_lower_than_ES2020: diag(2737, DiagnosticCategory.Error, "BigInt_literals_are_not_available_when_targeting_lower_than_ES2020_2737", "BigInt literals are not available when targeting lower than ES2020."), + An_outer_value_of_this_is_shadowed_by_this_container: diag(2738, DiagnosticCategory.Message, "An_outer_value_of_this_is_shadowed_by_this_container_2738", "An outer value of 'this' is shadowed by this container."), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2: diag(2739, DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739", "Type '{0}' is missing the following properties from type '{1}': {2}"), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more: diag(2740, DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740", "Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more."), + Property_0_is_missing_in_type_1_but_required_in_type_2: diag(2741, DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_but_required_in_type_2_2741", "Property '{0}' is missing in type '{1}' but required in type '{2}'."), + The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary: diag(2742, DiagnosticCategory.Error, "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742", "The inferred type of '{0}' cannot be named without a reference to '{1}'. This is likely not portable. A type annotation is necessary."), + No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments: diag(2743, DiagnosticCategory.Error, "No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments_2743", "No overload expects {0} type arguments, but overloads do exist that expect either {1} or {2} type arguments."), + Type_parameter_defaults_can_only_reference_previously_declared_type_parameters: diag(2744, DiagnosticCategory.Error, "Type_parameter_defaults_can_only_reference_previously_declared_type_parameters_2744", "Type parameter defaults can only reference previously declared type parameters."), + This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_provided: diag(2745, DiagnosticCategory.Error, "This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_pr_2745", "This JSX tag's '{0}' prop expects type '{1}' which requires multiple children, but only a single child was provided."), + This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided: diag(2746, DiagnosticCategory.Error, "This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided_2746", "This JSX tag's '{0}' prop expects a single child of type '{1}', but multiple children were provided."), + _0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2: diag(2747, DiagnosticCategory.Error, "_0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_t_2747", "'{0}' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of '{1}' is '{2}'."), + Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided: diag(2748, DiagnosticCategory.Error, "Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided_2748", "Cannot access ambient const enums when the '--isolatedModules' flag is provided."), + _0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0: diag(2749, DiagnosticCategory.Error, "_0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0_2749", "'{0}' refers to a value, but is being used as a type here. Did you mean 'typeof {0}'?"), + The_implementation_signature_is_declared_here: diag(2750, DiagnosticCategory.Error, "The_implementation_signature_is_declared_here_2750", "The implementation signature is declared here."), + Circularity_originates_in_type_at_this_location: diag(2751, DiagnosticCategory.Error, "Circularity_originates_in_type_at_this_location_2751", "Circularity originates in type at this location."), + The_first_export_default_is_here: diag(2752, DiagnosticCategory.Error, "The_first_export_default_is_here_2752", "The first export default is here."), + Another_export_default_is_here: diag(2753, DiagnosticCategory.Error, "Another_export_default_is_here_2753", "Another export default is here."), + super_may_not_use_type_arguments: diag(2754, DiagnosticCategory.Error, "super_may_not_use_type_arguments_2754", "'super' may not use type arguments."), + No_constituent_of_type_0_is_callable: diag(2755, DiagnosticCategory.Error, "No_constituent_of_type_0_is_callable_2755", "No constituent of type '{0}' is callable."), + Not_all_constituents_of_type_0_are_callable: diag(2756, DiagnosticCategory.Error, "Not_all_constituents_of_type_0_are_callable_2756", "Not all constituents of type '{0}' are callable."), + Type_0_has_no_call_signatures: diag(2757, DiagnosticCategory.Error, "Type_0_has_no_call_signatures_2757", "Type '{0}' has no call signatures."), + Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other: diag(2758, DiagnosticCategory.Error, "Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_2758", "Each member of the union type '{0}' has signatures, but none of those signatures are compatible with each other."), + No_constituent_of_type_0_is_constructable: diag(2759, DiagnosticCategory.Error, "No_constituent_of_type_0_is_constructable_2759", "No constituent of type '{0}' is constructable."), + Not_all_constituents_of_type_0_are_constructable: diag(2760, DiagnosticCategory.Error, "Not_all_constituents_of_type_0_are_constructable_2760", "Not all constituents of type '{0}' are constructable."), + Type_0_has_no_construct_signatures: diag(2761, DiagnosticCategory.Error, "Type_0_has_no_construct_signatures_2761", "Type '{0}' has no construct signatures."), + Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other: diag(2762, DiagnosticCategory.Error, "Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_2762", "Each member of the union type '{0}' has construct signatures, but none of those signatures are compatible with each other."), + Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0: diag(2763, DiagnosticCategory.Error, "Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_s_2763", "Cannot iterate value because the 'next' method of its iterator expects type '{1}', but for-of will always send '{0}'."), + Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0: diag(2764, DiagnosticCategory.Error, "Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_al_2764", "Cannot iterate value because the 'next' method of its iterator expects type '{1}', but array spread will always send '{0}'."), + Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0: diag(2765, DiagnosticCategory.Error, "Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring__2765", "Cannot iterate value because the 'next' method of its iterator expects type '{1}', but array destructuring will always send '{0}'."), + Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0: diag(2766, DiagnosticCategory.Error, "Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_co_2766", "Cannot delegate iteration to value because the 'next' method of its iterator expects type '{1}', but the containing generator will always send '{0}'."), + The_0_property_of_an_iterator_must_be_a_method: diag(2767, DiagnosticCategory.Error, "The_0_property_of_an_iterator_must_be_a_method_2767", "The '{0}' property of an iterator must be a method."), + The_0_property_of_an_async_iterator_must_be_a_method: diag(2768, DiagnosticCategory.Error, "The_0_property_of_an_async_iterator_must_be_a_method_2768", "The '{0}' property of an async iterator must be a method."), + No_overload_matches_this_call: diag(2769, DiagnosticCategory.Error, "No_overload_matches_this_call_2769", "No overload matches this call."), + The_last_overload_gave_the_following_error: diag(2770, DiagnosticCategory.Error, "The_last_overload_gave_the_following_error_2770", "The last overload gave the following error."), + The_last_overload_is_declared_here: diag(2771, DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), + Overload_0_of_1_2_gave_the_following_error: diag(2772, DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), + Did_you_forget_to_use_await: diag(2773, DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774", "This condition will always return true since this function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), + _0_needs_an_explicit_type_annotation: diag(2782, DiagnosticCategory.Message, "_0_needs_an_explicit_type_annotation_2782", "'{0}' needs an explicit type annotation."), + _0_is_specified_more_than_once_so_this_usage_will_be_overwritten: diag(2783, DiagnosticCategory.Error, "_0_is_specified_more_than_once_so_this_usage_will_be_overwritten_2783", "'{0}' is specified more than once, so this usage will be overwritten."), + get_and_set_accessors_cannot_declare_this_parameters: diag(2784, DiagnosticCategory.Error, "get_and_set_accessors_cannot_declare_this_parameters_2784", "'get' and 'set' accessors cannot declare 'this' parameters."), + This_spread_always_overwrites_this_property: diag(2785, DiagnosticCategory.Error, "This_spread_always_overwrites_this_property_2785", "This spread always overwrites this property."), + _0_cannot_be_used_as_a_JSX_component: diag(2786, DiagnosticCategory.Error, "_0_cannot_be_used_as_a_JSX_component_2786", "'{0}' cannot be used as a JSX component."), + Its_return_type_0_is_not_a_valid_JSX_element: diag(2787, DiagnosticCategory.Error, "Its_return_type_0_is_not_a_valid_JSX_element_2787", "Its return type '{0}' is not a valid JSX element."), + Its_instance_type_0_is_not_a_valid_JSX_element: diag(2788, DiagnosticCategory.Error, "Its_instance_type_0_is_not_a_valid_JSX_element_2788", "Its instance type '{0}' is not a valid JSX element."), + Its_element_type_0_is_not_a_valid_JSX_element: diag(2789, DiagnosticCategory.Error, "Its_element_type_0_is_not_a_valid_JSX_element_2789", "Its element type '{0}' is not a valid JSX element."), + The_operand_of_a_delete_operator_must_be_optional: diag(2790, DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_optional_2790", "The operand of a 'delete' operator must be optional."), + Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later: diag(2791, DiagnosticCategory.Error, "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791", "Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later."), + Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option: diag(2792, DiagnosticCategory.Error, "Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_th_2792", "Cannot find module '{0}'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?"), + The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible: diag(2793, DiagnosticCategory.Error, "The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_2793", "The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible."), + Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise: diag(2794, DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794", "Expected {0} arguments, but got {1}. Did you forget to include 'void' in your type argument to 'Promise'?"), + The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types: diag(2795, DiagnosticCategory.Error, "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795", "The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types."), + It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked: diag(2796, DiagnosticCategory.Error, "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796", "It is likely that you are missing a comma to separate these two template expressions. They form a tagged template expression which cannot be invoked."), + A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract: diag(2797, DiagnosticCategory.Error, "A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_2797", "A mixin class that extends from a type variable containing an abstract construct signature must also be declared 'abstract'."), + The_declaration_was_marked_as_deprecated_here: diag(2798, DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), + Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), + Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), + This_condition_will_always_return_true_since_this_0_is_always_defined: diag(2801, DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_is_always_defined_2801", "This condition will always return true since this '{0}' is always defined."), + Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), + Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), + Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), + Private_accessor_was_defined_without_a_getter: diag(2806, DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), + This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), + A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), + Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."), + Initializer_for_property_0: diag(2811, DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), + Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), + Class_declaration_cannot_implement_overload_list_for_0: diag(2813, DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), + Function_with_bodies_can_only_merge_with_classes_that_are_ambient: diag(2814, DiagnosticCategory.Error, "Function_with_bodies_can_only_merge_with_classes_that_are_ambient_2814", "Function with bodies can only merge with classes that are ambient."), + arguments_cannot_be_referenced_in_property_initializers: diag(2815, DiagnosticCategory.Error, "arguments_cannot_be_referenced_in_property_initializers_2815", "'arguments' cannot be referenced in property initializers."), + Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class: diag(2816, DiagnosticCategory.Error, "Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class_2816", "Cannot use 'this' in a static property initializer of a decorated class."), + Property_0_has_no_initializer_and_is_not_definitely_assigned_in_a_class_static_block: diag(2817, DiagnosticCategory.Error, "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_a_class_static_block_2817", "Property '{0}' has no initializer and is not definitely assigned in a class static block."), + Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializers: diag(2818, DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializer_2818", "Duplicate identifier '{0}'. Compiler reserves name '{1}' when emitting 'super' references in static initializers."), + Namespace_name_cannot_be_0: diag(2819, DiagnosticCategory.Error, "Namespace_name_cannot_be_0_2819", "Namespace name cannot be '{0}'."), + Type_0_is_not_assignable_to_type_1_Did_you_mean_2: diag(2820, DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_Did_you_mean_2_2820", "Type '{0}' is not assignable to type '{1}'. Did you mean '{2}'?"), + Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."), + Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."), + Cannot_find_namespace_0_Did_you_mean_1: diag(2833, DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"), + Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."), + Import_assertion_values_must_be_string_literal_expressions: diag(2837, DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), + All_declarations_of_0_must_have_identical_constraints: diag(2838, DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), + This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."), + An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"), + The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), + We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), + Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), + This_condition_will_always_return_0: diag(2845, DiagnosticCategory.Error, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."), + Import_declaration_0_is_using_private_name_1: diag(4000, DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), + Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), + Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), + Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4006, DiagnosticCategory.Error, "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006", "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'."), + Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4008, DiagnosticCategory.Error, "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008", "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'."), + Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: diag(4010, DiagnosticCategory.Error, "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010", "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'."), + Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: diag(4012, DiagnosticCategory.Error, "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012", "Type parameter '{0}' of public method from exported class has or is using private name '{1}'."), + Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: diag(4014, DiagnosticCategory.Error, "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", "Type parameter '{0}' of method from exported interface has or is using private name '{1}'."), + Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: diag(4016, DiagnosticCategory.Error, "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", "Type parameter '{0}' of exported function has or is using private name '{1}'."), + Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: diag(4019, DiagnosticCategory.Error, "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", "Implements clause of exported class '{0}' has or is using private name '{1}'."), + extends_clause_of_exported_class_0_has_or_is_using_private_name_1: diag(4020, DiagnosticCategory.Error, "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", "'extends' clause of exported class '{0}' has or is using private name '{1}'."), + extends_clause_of_exported_class_has_or_is_using_private_name_0: diag(4021, DiagnosticCategory.Error, "extends_clause_of_exported_class_has_or_is_using_private_name_0_4021", "'extends' clause of exported class has or is using private name '{0}'."), + extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: diag(4022, DiagnosticCategory.Error, "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", "'extends' clause of exported interface '{0}' has or is using private name '{1}'."), + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4023, DiagnosticCategory.Error, "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named."), + Exported_variable_0_has_or_is_using_name_1_from_private_module_2: diag(4024, DiagnosticCategory.Error, "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", "Exported variable '{0}' has or is using name '{1}' from private module '{2}'."), + Exported_variable_0_has_or_is_using_private_name_1: diag(4025, DiagnosticCategory.Error, "Exported_variable_0_has_or_is_using_private_name_1_4025", "Exported variable '{0}' has or is using private name '{1}'."), + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4026, DiagnosticCategory.Error, "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026", "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."), + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4027, DiagnosticCategory.Error, "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027", "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'."), + Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: diag(4028, DiagnosticCategory.Error, "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028", "Public static property '{0}' of exported class has or is using private name '{1}'."), + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4029, DiagnosticCategory.Error, "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029", "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."), + Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4030, DiagnosticCategory.Error, "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030", "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'."), + Public_property_0_of_exported_class_has_or_is_using_private_name_1: diag(4031, DiagnosticCategory.Error, "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031", "Public property '{0}' of exported class has or is using private name '{1}'."), + Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4032, DiagnosticCategory.Error, "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032", "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'."), + Property_0_of_exported_interface_has_or_is_using_private_name_1: diag(4033, DiagnosticCategory.Error, "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033", "Property '{0}' of exported interface has or is using private name '{1}'."), + Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4034, DiagnosticCategory.Error, "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_mod_4034", "Parameter type of public static setter '{0}' from exported class has or is using name '{1}' from private module '{2}'."), + Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1: diag(4035, DiagnosticCategory.Error, "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1_4035", "Parameter type of public static setter '{0}' from exported class has or is using private name '{1}'."), + Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4036, DiagnosticCategory.Error, "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4036", "Parameter type of public setter '{0}' from exported class has or is using name '{1}' from private module '{2}'."), + Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1: diag(4037, DiagnosticCategory.Error, "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1_4037", "Parameter type of public setter '{0}' from exported class has or is using private name '{1}'."), + Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4038, DiagnosticCategory.Error, "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_modul_4038", "Return type of public static getter '{0}' from exported class has or is using name '{1}' from external module {2} but cannot be named."), + Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4039, DiagnosticCategory.Error, "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_4039", "Return type of public static getter '{0}' from exported class has or is using name '{1}' from private module '{2}'."), + Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1: diag(4040, DiagnosticCategory.Error, "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1_4040", "Return type of public static getter '{0}' from exported class has or is using private name '{1}'."), + Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4041, DiagnosticCategory.Error, "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_4041", "Return type of public getter '{0}' from exported class has or is using name '{1}' from external module {2} but cannot be named."), + Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4042, DiagnosticCategory.Error, "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4042", "Return type of public getter '{0}' from exported class has or is using name '{1}' from private module '{2}'."), + Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1: diag(4043, DiagnosticCategory.Error, "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1_4043", "Return type of public getter '{0}' from exported class has or is using private name '{1}'."), + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4044, DiagnosticCategory.Error, "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044", "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'."), + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: diag(4045, DiagnosticCategory.Error, "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045", "Return type of constructor signature from exported interface has or is using private name '{0}'."), + Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4046, DiagnosticCategory.Error, "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046", "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'."), + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: diag(4047, DiagnosticCategory.Error, "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047", "Return type of call signature from exported interface has or is using private name '{0}'."), + Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4048, DiagnosticCategory.Error, "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048", "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'."), + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: diag(4049, DiagnosticCategory.Error, "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049", "Return type of index signature from exported interface has or is using private name '{0}'."), + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: diag(4050, DiagnosticCategory.Error, "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050", "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named."), + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: diag(4051, DiagnosticCategory.Error, "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051", "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'."), + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: diag(4052, DiagnosticCategory.Error, "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052", "Return type of public static method from exported class has or is using private name '{0}'."), + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: diag(4053, DiagnosticCategory.Error, "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053", "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named."), + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: diag(4054, DiagnosticCategory.Error, "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054", "Return type of public method from exported class has or is using name '{0}' from private module '{1}'."), + Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: diag(4055, DiagnosticCategory.Error, "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055", "Return type of public method from exported class has or is using private name '{0}'."), + Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4056, DiagnosticCategory.Error, "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056", "Return type of method from exported interface has or is using name '{0}' from private module '{1}'."), + Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: diag(4057, DiagnosticCategory.Error, "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057", "Return type of method from exported interface has or is using private name '{0}'."), + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: diag(4058, DiagnosticCategory.Error, "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058", "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named."), + Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: diag(4059, DiagnosticCategory.Error, "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059", "Return type of exported function has or is using name '{0}' from private module '{1}'."), + Return_type_of_exported_function_has_or_is_using_private_name_0: diag(4060, DiagnosticCategory.Error, "Return_type_of_exported_function_has_or_is_using_private_name_0_4060", "Return type of exported function has or is using private name '{0}'."), + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4061, DiagnosticCategory.Error, "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061", "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named."), + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4062, DiagnosticCategory.Error, "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062", "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: diag(4063, DiagnosticCategory.Error, "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063", "Parameter '{0}' of constructor from exported class has or is using private name '{1}'."), + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4064, DiagnosticCategory.Error, "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064", "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4065, DiagnosticCategory.Error, "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065", "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'."), + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4066, DiagnosticCategory.Error, "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066", "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4067, DiagnosticCategory.Error, "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067", "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'."), + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4068, DiagnosticCategory.Error, "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068", "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named."), + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4069, DiagnosticCategory.Error, "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069", "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: diag(4070, DiagnosticCategory.Error, "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070", "Parameter '{0}' of public static method from exported class has or is using private name '{1}'."), + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4071, DiagnosticCategory.Error, "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071", "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named."), + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4072, DiagnosticCategory.Error, "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072", "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: diag(4073, DiagnosticCategory.Error, "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073", "Parameter '{0}' of public method from exported class has or is using private name '{1}'."), + Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4074, DiagnosticCategory.Error, "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074", "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: diag(4075, DiagnosticCategory.Error, "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075", "Parameter '{0}' of method from exported interface has or is using private name '{1}'."), + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4076, DiagnosticCategory.Error, "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076", "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named."), + Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: diag(4077, DiagnosticCategory.Error, "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077", "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_exported_function_has_or_is_using_private_name_1: diag(4078, DiagnosticCategory.Error, "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078", "Parameter '{0}' of exported function has or is using private name '{1}'."), + Exported_type_alias_0_has_or_is_using_private_name_1: diag(4081, DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_4081", "Exported type alias '{0}' has or is using private name '{1}'."), + Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, DiagnosticCategory.Error, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."), + Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, DiagnosticCategory.Error, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."), + Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."), + Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, DiagnosticCategory.Error, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."), + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."), + Property_0_of_exported_class_expression_may_not_be_private_or_protected: diag(4094, DiagnosticCategory.Error, "Property_0_of_exported_class_expression_may_not_be_private_or_protected_4094", "Property '{0}' of exported class expression may not be private or protected."), + Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4095, DiagnosticCategory.Error, "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_4095", "Public static method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."), + Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4096, DiagnosticCategory.Error, "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4096", "Public static method '{0}' of exported class has or is using name '{1}' from private module '{2}'."), + Public_static_method_0_of_exported_class_has_or_is_using_private_name_1: diag(4097, DiagnosticCategory.Error, "Public_static_method_0_of_exported_class_has_or_is_using_private_name_1_4097", "Public static method '{0}' of exported class has or is using private name '{1}'."), + Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4098, DiagnosticCategory.Error, "Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4098", "Public method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."), + Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4099, DiagnosticCategory.Error, "Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4099", "Public method '{0}' of exported class has or is using name '{1}' from private module '{2}'."), + Public_method_0_of_exported_class_has_or_is_using_private_name_1: diag(4100, DiagnosticCategory.Error, "Public_method_0_of_exported_class_has_or_is_using_private_name_1_4100", "Public method '{0}' of exported class has or is using private name '{1}'."), + Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4101, DiagnosticCategory.Error, "Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4101", "Method '{0}' of exported interface has or is using name '{1}' from private module '{2}'."), + Method_0_of_exported_interface_has_or_is_using_private_name_1: diag(4102, DiagnosticCategory.Error, "Method_0_of_exported_interface_has_or_is_using_private_name_1_4102", "Method '{0}' of exported interface has or is using private name '{1}'."), + Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), + The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), + Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), + Type_arguments_for_0_circularly_reference_themselves: diag(4109, DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), + Tuple_type_arguments_circularly_reference_themselves: diag(4110, DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), + Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0: diag(4111, DiagnosticCategory.Error, "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111", "Property '{0}' comes from an index signature, so it must be accessed with ['{0}']."), + This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class: diag(4112, DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another__4112", "This member cannot have an 'override' modifier because its containing class '{0}' does not extend another class."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0: diag(4113, DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_4113", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0: diag(4114, DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114", "This member must have an 'override' modifier because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0: diag(4115, DiagnosticCategory.Error, "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115", "This parameter property must have an 'override' modifier because it overrides a member in base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0: diag(4116, DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116", "This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4117, DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you__4117", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'. Did you mean '{1}'?"), + The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized: diag(4118, DiagnosticCategory.Error, "The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized_4118", "The type of this node cannot be serialized because its property '{0}' cannot be serialized."), + This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0: diag(4119, DiagnosticCategory.Error, "This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_4119", "This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0: diag(4120, DiagnosticCategory.Error, "This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_4120", "This parameter property must have a JSDoc comment with an '@override' tag because it overrides a member in the base class '{0}'."), + This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class: diag(4121, DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_4121", "This member cannot have a JSDoc comment with an '@override' tag because its containing class '{0}' does not extend another class."), + This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."), + This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"), + Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, DiagnosticCategory.Error, "resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "'resolution-mode' assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + The_current_host_does_not_support_the_0_option: diag(5001, DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), + Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), + File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), + Cannot_read_file_0_Colon_1: diag(5012, DiagnosticCategory.Error, "Cannot_read_file_0_Colon_1_5012", "Cannot read file '{0}': {1}."), + Failed_to_parse_file_0_Colon_1: diag(5014, DiagnosticCategory.Error, "Failed_to_parse_file_0_Colon_1_5014", "Failed to parse file '{0}': {1}."), + Unknown_compiler_option_0: diag(5023, DiagnosticCategory.Error, "Unknown_compiler_option_0_5023", "Unknown compiler option '{0}'."), + Compiler_option_0_requires_a_value_of_type_1: diag(5024, DiagnosticCategory.Error, "Compiler_option_0_requires_a_value_of_type_1_5024", "Compiler option '{0}' requires a value of type {1}."), + Unknown_compiler_option_0_Did_you_mean_1: diag(5025, DiagnosticCategory.Error, "Unknown_compiler_option_0_Did_you_mean_1_5025", "Unknown compiler option '{0}'. Did you mean '{1}'?"), + Could_not_write_file_0_Colon_1: diag(5033, DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), + Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), + Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), + Option_0_cannot_be_specified_with_option_1: diag(5053, DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), + A_tsconfig_json_file_is_already_defined_at_Colon_0: diag(5054, DiagnosticCategory.Error, "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", "A 'tsconfig.json' file is already defined at: '{0}'."), + Cannot_write_file_0_because_it_would_overwrite_input_file: diag(5055, DiagnosticCategory.Error, "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", "Cannot write file '{0}' because it would overwrite input file."), + Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: diag(5056, DiagnosticCategory.Error, "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056", "Cannot write file '{0}' because it would be overwritten by multiple input files."), + Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: diag(5057, DiagnosticCategory.Error, "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057", "Cannot find a tsconfig.json file at the specified directory: '{0}'."), + The_specified_path_does_not_exist_Colon_0: diag(5058, DiagnosticCategory.Error, "The_specified_path_does_not_exist_Colon_0_5058", "The specified path does not exist: '{0}'."), + Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."), + Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."), + Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."), + Substitutions_for_pattern_0_should_be_an_array: diag(5063, DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."), + Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."), + File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."), + Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: diag(5066, DiagnosticCategory.Error, "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066", "Substitutions for pattern '{0}' shouldn't be an empty array."), + Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(5067, DiagnosticCategory.Error, "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067", "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name."), + Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: diag(5068, DiagnosticCategory.Error, "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068", "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig."), + Option_0_cannot_be_specified_without_specifying_option_1_or_option_2: diag(5069, DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_or_option_2_5069", "Option '{0}' cannot be specified without specifying option '{1}' or option '{2}'."), + Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy: diag(5070, DiagnosticCategory.Error, "Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy_5070", "Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy."), + Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext: diag(5071, DiagnosticCategory.Error, "Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_5071", "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'."), + Unknown_build_option_0: diag(5072, DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."), + Build_option_0_requires_a_value_of_type_1: diag(5073, DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), + Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified."), + _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), + Unknown_build_option_0_Did_you_mean_1: diag(5077, DiagnosticCategory.Error, "Unknown_build_option_0_Did_you_mean_1_5077", "Unknown build option '{0}'. Did you mean '{1}'?"), + Unknown_watch_option_0: diag(5078, DiagnosticCategory.Error, "Unknown_watch_option_0_5078", "Unknown watch option '{0}'."), + Unknown_watch_option_0_Did_you_mean_1: diag(5079, DiagnosticCategory.Error, "Unknown_watch_option_0_Did_you_mean_1_5079", "Unknown watch option '{0}'. Did you mean '{1}'?"), + Watch_option_0_requires_a_value_of_type_1: diag(5080, DiagnosticCategory.Error, "Watch_option_0_requires_a_value_of_type_1_5080", "Watch option '{0}' requires a value of type {1}."), + Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0: diag(5081, DiagnosticCategory.Error, "Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0_5081", "Cannot find a tsconfig.json file at the current directory: {0}."), + _0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1: diag(5082, DiagnosticCategory.Error, "_0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1_5082", "'{0}' could be instantiated with an arbitrary type which could be unrelated to '{1}'."), + Cannot_read_file_0: diag(5083, DiagnosticCategory.Error, "Cannot_read_file_0_5083", "Cannot read file '{0}'."), + Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, DiagnosticCategory.Error, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."), + A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, DiagnosticCategory.Error, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."), + A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."), + A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a '...' before the name, rather than before the type."), + The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."), + Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."), + Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"), + Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled: diag(5091, DiagnosticCategory.Error, "Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled_5091", "Option 'preserveConstEnums' cannot be disabled when 'isolatedModules' is enabled."), + The_root_value_of_a_0_file_must_be_an_object: diag(5092, DiagnosticCategory.Error, "The_root_value_of_a_0_file_must_be_an_object_5092", "The root value of a '{0}' file must be an object."), + Compiler_option_0_may_only_be_used_with_build: diag(5093, DiagnosticCategory.Error, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."), + Compiler_option_0_may_not_be_used_with_build: diag(5094, DiagnosticCategory.Error, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."), + Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later: diag(5095, DiagnosticCategory.Error, "Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later_5095", "Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later."), + Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), + Concatenate_and_emit_output_to_single_file: diag(6001, DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), + Generates_corresponding_d_ts_file: diag(6002, DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), + Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: diag(6004, DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004", "Specify the location where debugger should locate TypeScript files instead of source locations."), + Watch_input_files: diag(6005, DiagnosticCategory.Message, "Watch_input_files_6005", "Watch input files."), + Redirect_output_structure_to_the_directory: diag(6006, DiagnosticCategory.Message, "Redirect_output_structure_to_the_directory_6006", "Redirect output structure to the directory."), + Do_not_erase_const_enum_declarations_in_generated_code: diag(6007, DiagnosticCategory.Message, "Do_not_erase_const_enum_declarations_in_generated_code_6007", "Do not erase const enum declarations in generated code."), + Do_not_emit_outputs_if_any_errors_were_reported: diag(6008, DiagnosticCategory.Message, "Do_not_emit_outputs_if_any_errors_were_reported_6008", "Do not emit outputs if any errors were reported."), + Do_not_emit_comments_to_output: diag(6009, DiagnosticCategory.Message, "Do_not_emit_comments_to_output_6009", "Do not emit comments to output."), + Do_not_emit_outputs: diag(6010, DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."), + Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: diag(6011, DiagnosticCategory.Message, "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", "Allow default imports from modules with no default export. This does not affect code emit, just typechecking."), + Skip_type_checking_of_declaration_files: diag(6012, DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), + Do_not_resolve_the_real_path_of_symlinks: diag(6013, DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), + Only_emit_d_ts_declaration_files: diag(6014, DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."), + Specify_ECMAScript_target_version: diag(6015, DiagnosticCategory.Message, "Specify_ECMAScript_target_version_6015", "Specify ECMAScript target version."), + Specify_module_code_generation: diag(6016, DiagnosticCategory.Message, "Specify_module_code_generation_6016", "Specify module code generation."), + Print_this_message: diag(6017, DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), + Print_the_compiler_s_version: diag(6019, DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."), + Syntax_Colon_0: diag(6023, DiagnosticCategory.Message, "Syntax_Colon_0_6023", "Syntax: {0}"), + options: diag(6024, DiagnosticCategory.Message, "options_6024", "options"), + file: diag(6025, DiagnosticCategory.Message, "file_6025", "file"), + Examples_Colon_0: diag(6026, DiagnosticCategory.Message, "Examples_Colon_0_6026", "Examples: {0}"), + Options_Colon: diag(6027, DiagnosticCategory.Message, "Options_Colon_6027", "Options:"), + Version_0: diag(6029, DiagnosticCategory.Message, "Version_0_6029", "Version {0}"), + Insert_command_line_options_and_files_from_a_file: diag(6030, DiagnosticCategory.Message, "Insert_command_line_options_and_files_from_a_file_6030", "Insert command line options and files from a file."), + Starting_compilation_in_watch_mode: diag(6031, DiagnosticCategory.Message, "Starting_compilation_in_watch_mode_6031", "Starting compilation in watch mode..."), + File_change_detected_Starting_incremental_compilation: diag(6032, DiagnosticCategory.Message, "File_change_detected_Starting_incremental_compilation_6032", "File change detected. Starting incremental compilation..."), + KIND: diag(6034, DiagnosticCategory.Message, "KIND_6034", "KIND"), + FILE: diag(6035, DiagnosticCategory.Message, "FILE_6035", "FILE"), + VERSION: diag(6036, DiagnosticCategory.Message, "VERSION_6036", "VERSION"), + LOCATION: diag(6037, DiagnosticCategory.Message, "LOCATION_6037", "LOCATION"), + DIRECTORY: diag(6038, DiagnosticCategory.Message, "DIRECTORY_6038", "DIRECTORY"), + STRATEGY: diag(6039, DiagnosticCategory.Message, "STRATEGY_6039", "STRATEGY"), + FILE_OR_DIRECTORY: diag(6040, DiagnosticCategory.Message, "FILE_OR_DIRECTORY_6040", "FILE OR DIRECTORY"), + Errors_Files: diag(6041, DiagnosticCategory.Message, "Errors_Files_6041", "Errors Files"), + Generates_corresponding_map_file: diag(6043, DiagnosticCategory.Message, "Generates_corresponding_map_file_6043", "Generates corresponding '.map' file."), + Compiler_option_0_expects_an_argument: diag(6044, DiagnosticCategory.Error, "Compiler_option_0_expects_an_argument_6044", "Compiler option '{0}' expects an argument."), + Unterminated_quoted_string_in_response_file_0: diag(6045, DiagnosticCategory.Error, "Unterminated_quoted_string_in_response_file_0_6045", "Unterminated quoted string in response file '{0}'."), + Argument_for_0_option_must_be_Colon_1: diag(6046, DiagnosticCategory.Error, "Argument_for_0_option_must_be_Colon_1_6046", "Argument for '{0}' option must be: {1}."), + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: diag(6048, DiagnosticCategory.Error, "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", "Locale must be of the form or -. For example '{0}' or '{1}'."), + Unable_to_open_file_0: diag(6050, DiagnosticCategory.Error, "Unable_to_open_file_0_6050", "Unable to open file '{0}'."), + Corrupted_locale_file_0: diag(6051, DiagnosticCategory.Error, "Corrupted_locale_file_0_6051", "Corrupted locale file {0}."), + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: diag(6052, DiagnosticCategory.Message, "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052", "Raise error on expressions and declarations with an implied 'any' type."), + File_0_not_found: diag(6053, DiagnosticCategory.Error, "File_0_not_found_6053", "File '{0}' not found."), + File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1: diag(6054, DiagnosticCategory.Error, "File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1_6054", "File '{0}' has an unsupported extension. The only supported extensions are {1}."), + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: diag(6055, DiagnosticCategory.Message, "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055", "Suppress noImplicitAny errors for indexing objects lacking index signatures."), + Do_not_emit_declarations_for_code_that_has_an_internal_annotation: diag(6056, DiagnosticCategory.Message, "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056", "Do not emit declarations for code that has an '@internal' annotation."), + Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: diag(6058, DiagnosticCategory.Message, "Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir_6058", "Specify the root directory of input files. Use to control the output directory structure with --outDir."), + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: diag(6059, DiagnosticCategory.Error, "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files."), + Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: diag(6060, DiagnosticCategory.Message, "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)."), + NEWLINE: diag(6061, DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."), + Enables_experimental_support_for_ES7_decorators: diag(6065, DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."), + Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."), + Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: diag(6069, DiagnosticCategory.Message, "Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", "Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)."), + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: diag(6070, DiagnosticCategory.Message, "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", "Initializes a TypeScript project and creates a tsconfig.json file."), + Successfully_created_a_tsconfig_json_file: diag(6071, DiagnosticCategory.Message, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."), + Suppress_excess_property_checks_for_object_literals: diag(6072, DiagnosticCategory.Message, "Suppress_excess_property_checks_for_object_literals_6072", "Suppress excess property checks for object literals."), + Stylize_errors_and_messages_using_color_and_context_experimental: diag(6073, DiagnosticCategory.Message, "Stylize_errors_and_messages_using_color_and_context_experimental_6073", "Stylize errors and messages using color and context (experimental)."), + Do_not_report_errors_on_unused_labels: diag(6074, DiagnosticCategory.Message, "Do_not_report_errors_on_unused_labels_6074", "Do not report errors on unused labels."), + Report_error_when_not_all_code_paths_in_function_return_a_value: diag(6075, DiagnosticCategory.Message, "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", "Report error when not all code paths in function return a value."), + Report_errors_for_fallthrough_cases_in_switch_statement: diag(6076, DiagnosticCategory.Message, "Report_errors_for_fallthrough_cases_in_switch_statement_6076", "Report errors for fallthrough cases in switch statement."), + Do_not_report_errors_on_unreachable_code: diag(6077, DiagnosticCategory.Message, "Do_not_report_errors_on_unreachable_code_6077", "Do not report errors on unreachable code."), + Disallow_inconsistently_cased_references_to_the_same_file: diag(6078, DiagnosticCategory.Message, "Disallow_inconsistently_cased_references_to_the_same_file_6078", "Disallow inconsistently-cased references to the same file."), + Specify_library_files_to_be_included_in_the_compilation: diag(6079, DiagnosticCategory.Message, "Specify_library_files_to_be_included_in_the_compilation_6079", "Specify library files to be included in the compilation."), + Specify_JSX_code_generation: diag(6080, DiagnosticCategory.Message, "Specify_JSX_code_generation_6080", "Specify JSX code generation."), + File_0_has_an_unsupported_extension_so_skipping_it: diag(6081, DiagnosticCategory.Message, "File_0_has_an_unsupported_extension_so_skipping_it_6081", "File '{0}' has an unsupported extension, so skipping it."), + Only_amd_and_system_modules_are_supported_alongside_0: diag(6082, DiagnosticCategory.Error, "Only_amd_and_system_modules_are_supported_alongside_0_6082", "Only 'amd' and 'system' modules are supported alongside --{0}."), + Base_directory_to_resolve_non_absolute_module_names: diag(6083, DiagnosticCategory.Message, "Base_directory_to_resolve_non_absolute_module_names_6083", "Base directory to resolve non-absolute module names."), + Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: diag(6084, DiagnosticCategory.Message, "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084", "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit"), + Enable_tracing_of_the_name_resolution_process: diag(6085, DiagnosticCategory.Message, "Enable_tracing_of_the_name_resolution_process_6085", "Enable tracing of the name resolution process."), + Resolving_module_0_from_1: diag(6086, DiagnosticCategory.Message, "Resolving_module_0_from_1_6086", "======== Resolving module '{0}' from '{1}'. ========"), + Explicitly_specified_module_resolution_kind_Colon_0: diag(6087, DiagnosticCategory.Message, "Explicitly_specified_module_resolution_kind_Colon_0_6087", "Explicitly specified module resolution kind: '{0}'."), + Module_resolution_kind_is_not_specified_using_0: diag(6088, DiagnosticCategory.Message, "Module_resolution_kind_is_not_specified_using_0_6088", "Module resolution kind is not specified, using '{0}'."), + Module_name_0_was_successfully_resolved_to_1: diag(6089, DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_6089", "======== Module name '{0}' was successfully resolved to '{1}'. ========"), + Module_name_0_was_not_resolved: diag(6090, DiagnosticCategory.Message, "Module_name_0_was_not_resolved_6090", "======== Module name '{0}' was not resolved. ========"), + paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: diag(6091, DiagnosticCategory.Message, "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091", "'paths' option is specified, looking for a pattern to match module name '{0}'."), + Module_name_0_matched_pattern_1: diag(6092, DiagnosticCategory.Message, "Module_name_0_matched_pattern_1_6092", "Module name '{0}', matched pattern '{1}'."), + Trying_substitution_0_candidate_module_location_Colon_1: diag(6093, DiagnosticCategory.Message, "Trying_substitution_0_candidate_module_location_Colon_1_6093", "Trying substitution '{0}', candidate module location: '{1}'."), + Resolving_module_name_0_relative_to_base_url_1_2: diag(6094, DiagnosticCategory.Message, "Resolving_module_name_0_relative_to_base_url_1_2_6094", "Resolving module name '{0}' relative to base url '{1}' - '{2}'."), + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1: diag(6095, DiagnosticCategory.Message, "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1_6095", "Loading module as file / folder, candidate module location '{0}', target file types: {1}."), + File_0_does_not_exist: diag(6096, DiagnosticCategory.Message, "File_0_does_not_exist_6096", "File '{0}' does not exist."), + File_0_exist_use_it_as_a_name_resolution_result: diag(6097, DiagnosticCategory.Message, "File_0_exist_use_it_as_a_name_resolution_result_6097", "File '{0}' exist - use it as a name resolution result."), + Loading_module_0_from_node_modules_folder_target_file_types_Colon_1: diag(6098, DiagnosticCategory.Message, "Loading_module_0_from_node_modules_folder_target_file_types_Colon_1_6098", "Loading module '{0}' from 'node_modules' folder, target file types: {1}."), + Found_package_json_at_0: diag(6099, DiagnosticCategory.Message, "Found_package_json_at_0_6099", "Found 'package.json' at '{0}'."), + package_json_does_not_have_a_0_field: diag(6100, DiagnosticCategory.Message, "package_json_does_not_have_a_0_field_6100", "'package.json' does not have a '{0}' field."), + package_json_has_0_field_1_that_references_2: diag(6101, DiagnosticCategory.Message, "package_json_has_0_field_1_that_references_2_6101", "'package.json' has '{0}' field '{1}' that references '{2}'."), + Allow_javascript_files_to_be_compiled: diag(6102, DiagnosticCategory.Message, "Allow_javascript_files_to_be_compiled_6102", "Allow javascript files to be compiled."), + Checking_if_0_is_the_longest_matching_prefix_for_1_2: diag(6104, DiagnosticCategory.Message, "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104", "Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'."), + Expected_type_of_0_field_in_package_json_to_be_1_got_2: diag(6105, DiagnosticCategory.Message, "Expected_type_of_0_field_in_package_json_to_be_1_got_2_6105", "Expected type of '{0}' field in 'package.json' to be '{1}', got '{2}'."), + baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: diag(6106, DiagnosticCategory.Message, "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106", "'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'."), + rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: diag(6107, DiagnosticCategory.Message, "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107", "'rootDirs' option is set, using it to resolve relative module name '{0}'."), + Longest_matching_prefix_for_0_is_1: diag(6108, DiagnosticCategory.Message, "Longest_matching_prefix_for_0_is_1_6108", "Longest matching prefix for '{0}' is '{1}'."), + Loading_0_from_the_root_dir_1_candidate_location_2: diag(6109, DiagnosticCategory.Message, "Loading_0_from_the_root_dir_1_candidate_location_2_6109", "Loading '{0}' from the root dir '{1}', candidate location '{2}'."), + Trying_other_entries_in_rootDirs: diag(6110, DiagnosticCategory.Message, "Trying_other_entries_in_rootDirs_6110", "Trying other entries in 'rootDirs'."), + Module_resolution_using_rootDirs_has_failed: diag(6111, DiagnosticCategory.Message, "Module_resolution_using_rootDirs_has_failed_6111", "Module resolution using 'rootDirs' has failed."), + Do_not_emit_use_strict_directives_in_module_output: diag(6112, DiagnosticCategory.Message, "Do_not_emit_use_strict_directives_in_module_output_6112", "Do not emit 'use strict' directives in module output."), + Enable_strict_null_checks: diag(6113, DiagnosticCategory.Message, "Enable_strict_null_checks_6113", "Enable strict null checks."), + Unknown_option_excludes_Did_you_mean_exclude: diag(6114, DiagnosticCategory.Error, "Unknown_option_excludes_Did_you_mean_exclude_6114", "Unknown option 'excludes'. Did you mean 'exclude'?"), + Raise_error_on_this_expressions_with_an_implied_any_type: diag(6115, DiagnosticCategory.Message, "Raise_error_on_this_expressions_with_an_implied_any_type_6115", "Raise error on 'this' expressions with an implied 'any' type."), + Resolving_type_reference_directive_0_containing_file_1_root_directory_2: diag(6116, DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_root_directory_2_6116", "======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========"), + Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: diag(6119, DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========"), + Type_reference_directive_0_was_not_resolved: diag(6120, DiagnosticCategory.Message, "Type_reference_directive_0_was_not_resolved_6120", "======== Type reference directive '{0}' was not resolved. ========"), + Resolving_with_primary_search_path_0: diag(6121, DiagnosticCategory.Message, "Resolving_with_primary_search_path_0_6121", "Resolving with primary search path '{0}'."), + Root_directory_cannot_be_determined_skipping_primary_search_paths: diag(6122, DiagnosticCategory.Message, "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122", "Root directory cannot be determined, skipping primary search paths."), + Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: diag(6123, DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123", "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========"), + Type_declaration_files_to_be_included_in_compilation: diag(6124, DiagnosticCategory.Message, "Type_declaration_files_to_be_included_in_compilation_6124", "Type declaration files to be included in compilation."), + Looking_up_in_node_modules_folder_initial_location_0: diag(6125, DiagnosticCategory.Message, "Looking_up_in_node_modules_folder_initial_location_0_6125", "Looking up in 'node_modules' folder, initial location '{0}'."), + Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: diag(6126, DiagnosticCategory.Message, "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126", "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder."), + Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: diag(6127, DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127", "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========"), + Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: diag(6128, DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========"), + Resolving_real_path_for_0_result_1: diag(6130, DiagnosticCategory.Message, "Resolving_real_path_for_0_result_1_6130", "Resolving real path for '{0}', result '{1}'."), + Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: diag(6131, DiagnosticCategory.Error, "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'."), + File_name_0_has_a_1_extension_stripping_it: diag(6132, DiagnosticCategory.Message, "File_name_0_has_a_1_extension_stripping_it_6132", "File name '{0}' has a '{1}' extension - stripping it."), + _0_is_declared_but_its_value_is_never_read: diag(6133, DiagnosticCategory.Error, "_0_is_declared_but_its_value_is_never_read_6133", "'{0}' is declared but its value is never read.", /*reportsUnnecessary*/ true), + Report_errors_on_unused_locals: diag(6134, DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."), + Report_errors_on_unused_parameters: diag(6135, DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."), + The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: diag(6136, DiagnosticCategory.Message, "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", "The maximum dependency depth to search under node_modules and load JavaScript files."), + Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: diag(6137, DiagnosticCategory.Error, "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137", "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'."), + Property_0_is_declared_but_its_value_is_never_read: diag(6138, DiagnosticCategory.Error, "Property_0_is_declared_but_its_value_is_never_read_6138", "Property '{0}' is declared but its value is never read.", /*reportsUnnecessary*/ true), + Import_emit_helpers_from_tslib: diag(6139, DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."), + Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: diag(6140, DiagnosticCategory.Error, "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'."), + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, DiagnosticCategory.Message, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", "Parse in strict mode and emit \"use strict\" for each source file."), + Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."), + Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, DiagnosticCategory.Message, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."), + Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, DiagnosticCategory.Message, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."), + Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, DiagnosticCategory.Message, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."), + Resolution_for_module_0_was_found_in_cache_from_location_1: diag(6147, DiagnosticCategory.Message, "Resolution_for_module_0_was_found_in_cache_from_location_1_6147", "Resolution for module '{0}' was found in cache from location '{1}'."), + Directory_0_does_not_exist_skipping_all_lookups_in_it: diag(6148, DiagnosticCategory.Message, "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", "Directory '{0}' does not exist, skipping all lookups in it."), + Show_diagnostic_information: diag(6149, DiagnosticCategory.Message, "Show_diagnostic_information_6149", "Show diagnostic information."), + Show_verbose_diagnostic_information: diag(6150, DiagnosticCategory.Message, "Show_verbose_diagnostic_information_6150", "Show verbose diagnostic information."), + Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: diag(6151, DiagnosticCategory.Message, "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151", "Emit a single file with source maps instead of having a separate file."), + Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: diag(6152, DiagnosticCategory.Message, "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152", "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set."), + Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: diag(6153, DiagnosticCategory.Message, "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153", "Transpile each file as a separate module (similar to 'ts.transpileModule')."), + Print_names_of_generated_files_part_of_the_compilation: diag(6154, DiagnosticCategory.Message, "Print_names_of_generated_files_part_of_the_compilation_6154", "Print names of generated files part of the compilation."), + Print_names_of_files_part_of_the_compilation: diag(6155, DiagnosticCategory.Message, "Print_names_of_files_part_of_the_compilation_6155", "Print names of files part of the compilation."), + The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: diag(6156, DiagnosticCategory.Message, "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156", "The locale used when displaying messages to the user (e.g. 'en-us')"), + Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: diag(6157, DiagnosticCategory.Message, "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157", "Do not generate custom helper functions like '__extends' in compiled output."), + Do_not_include_the_default_library_file_lib_d_ts: diag(6158, DiagnosticCategory.Message, "Do_not_include_the_default_library_file_lib_d_ts_6158", "Do not include the default library file (lib.d.ts)."), + Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: diag(6159, DiagnosticCategory.Message, "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159", "Do not add triple-slash references or imported modules to the list of compiled files."), + Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: diag(6160, DiagnosticCategory.Message, "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160", "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files."), + List_of_folders_to_include_type_definitions_from: diag(6161, DiagnosticCategory.Message, "List_of_folders_to_include_type_definitions_from_6161", "List of folders to include type definitions from."), + Disable_size_limitations_on_JavaScript_projects: diag(6162, DiagnosticCategory.Message, "Disable_size_limitations_on_JavaScript_projects_6162", "Disable size limitations on JavaScript projects."), + The_character_set_of_the_input_files: diag(6163, DiagnosticCategory.Message, "The_character_set_of_the_input_files_6163", "The character set of the input files."), + Do_not_truncate_error_messages: diag(6165, DiagnosticCategory.Message, "Do_not_truncate_error_messages_6165", "Do not truncate error messages."), + Output_directory_for_generated_declaration_files: diag(6166, DiagnosticCategory.Message, "Output_directory_for_generated_declaration_files_6166", "Output directory for generated declaration files."), + A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: diag(6167, DiagnosticCategory.Message, "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'."), + List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: diag(6168, DiagnosticCategory.Message, "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168", "List of root folders whose combined content represents the structure of the project at runtime."), + Show_all_compiler_options: diag(6169, DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."), + Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"), + Command_line_Options: diag(6171, DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"), + Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."), + Enable_all_strict_type_checking_options: diag(6180, DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."), + Scoped_package_detected_looking_in_0: diag(6182, DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6183, DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6184, DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), + Enable_strict_checking_of_function_types: diag(6186, DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."), + Enable_strict_checking_of_property_initialization_in_classes: diag(6187, DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."), + Numeric_separators_are_not_allowed_here: diag(6188, DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."), + Multiple_consecutive_numeric_separators_are_not_permitted: diag(6189, DiagnosticCategory.Error, "Multiple_consecutive_numeric_separators_are_not_permitted_6189", "Multiple consecutive numeric separators are not permitted."), + Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: diag(6191, DiagnosticCategory.Message, "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191", "Whether to keep outdated console output in watch mode instead of clearing the screen."), + All_imports_in_import_declaration_are_unused: diag(6192, DiagnosticCategory.Error, "All_imports_in_import_declaration_are_unused_6192", "All imports in import declaration are unused.", /*reportsUnnecessary*/ true), + Found_1_error_Watching_for_file_changes: diag(6193, DiagnosticCategory.Message, "Found_1_error_Watching_for_file_changes_6193", "Found 1 error. Watching for file changes."), + Found_0_errors_Watching_for_file_changes: diag(6194, DiagnosticCategory.Message, "Found_0_errors_Watching_for_file_changes_6194", "Found {0} errors. Watching for file changes."), + Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols: diag(6195, DiagnosticCategory.Message, "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195", "Resolve 'keyof' to string valued property names only (no numbers or symbols)."), + _0_is_declared_but_never_used: diag(6196, DiagnosticCategory.Error, "_0_is_declared_but_never_used_6196", "'{0}' is declared but never used.", /*reportsUnnecessary*/ true), + Include_modules_imported_with_json_extension: diag(6197, DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), + All_destructured_elements_are_unused: diag(6198, DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", /*reportsUnnecessary*/ true), + All_variables_are_unused: diag(6199, DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), + _0_was_also_declared_here: diag(6203, DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, DiagnosticCategory.Message, "and_here_6204", "and here."), + All_type_parameters_are_unused: diag(6205, DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused."), + package_json_has_a_typesVersions_field_with_version_specific_path_mappings: diag(6206, DiagnosticCategory.Message, "package_json_has_a_typesVersions_field_with_version_specific_path_mappings_6206", "'package.json' has a 'typesVersions' field with version-specific path mappings."), + package_json_does_not_have_a_typesVersions_entry_that_matches_version_0: diag(6207, DiagnosticCategory.Message, "package_json_does_not_have_a_typesVersions_entry_that_matches_version_0_6207", "'package.json' does not have a 'typesVersions' entry that matches version '{0}'."), + package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2: diag(6208, DiagnosticCategory.Message, "package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_ma_6208", "'package.json' has a 'typesVersions' entry '{0}' that matches compiler version '{1}', looking for a pattern to match module name '{2}'."), + package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range: diag(6209, DiagnosticCategory.Message, "package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range_6209", "'package.json' has a 'typesVersions' entry '{0}' that is not a valid semver range."), + An_argument_for_0_was_not_provided: diag(6210, DiagnosticCategory.Message, "An_argument_for_0_was_not_provided_6210", "An argument for '{0}' was not provided."), + An_argument_matching_this_binding_pattern_was_not_provided: diag(6211, DiagnosticCategory.Message, "An_argument_matching_this_binding_pattern_was_not_provided_6211", "An argument matching this binding pattern was not provided."), + Did_you_mean_to_call_this_expression: diag(6212, DiagnosticCategory.Message, "Did_you_mean_to_call_this_expression_6212", "Did you mean to call this expression?"), + Did_you_mean_to_use_new_with_this_expression: diag(6213, DiagnosticCategory.Message, "Did_you_mean_to_use_new_with_this_expression_6213", "Did you mean to use 'new' with this expression?"), + Enable_strict_bind_call_and_apply_methods_on_functions: diag(6214, DiagnosticCategory.Message, "Enable_strict_bind_call_and_apply_methods_on_functions_6214", "Enable strict 'bind', 'call', and 'apply' methods on functions."), + Using_compiler_options_of_project_reference_redirect_0: diag(6215, DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."), + Found_1_error: diag(6216, DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."), + Found_0_errors: diag(6217, DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."), + Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), + Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), + package_json_had_a_falsy_0_field: diag(6220, DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), + Disable_solution_searching_for_this_project: diag(6224, DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."), + Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), + Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling: diag(6226, DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling'."), + Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize: diag(6227, DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority', 'FixedChunkSize'."), + Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), + Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), + Could_not_resolve_the_path_0_with_the_extensions_Colon_1: diag(6231, DiagnosticCategory.Error, "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231", "Could not resolve the path '{0}' with the extensions: {1}."), + Declaration_augments_declaration_in_another_file_This_cannot_be_serialized: diag(6232, DiagnosticCategory.Error, "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232", "Declaration augments declaration in another file. This cannot be serialized."), + This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file: diag(6233, DiagnosticCategory.Error, "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233", "This is the declaration being augmented. Consider moving the augmenting declaration into the same file."), + This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without: diag(6234, DiagnosticCategory.Error, "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234", "This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?"), + Disable_loading_referenced_projects: diag(6235, DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."), + Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."), + Generates_an_event_trace_and_a_list_of_types: diag(6237, DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."), + Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the 'jsx' and 'jsxs' factory functions from. eg, react"), + File_0_exists_according_to_earlier_cached_lookups: diag(6239, DiagnosticCategory.Message, "File_0_exists_according_to_earlier_cached_lookups_6239", "File '{0}' exists according to earlier cached lookups."), + File_0_does_not_exist_according_to_earlier_cached_lookups: diag(6240, DiagnosticCategory.Message, "File_0_does_not_exist_according_to_earlier_cached_lookups_6240", "File '{0}' does not exist according to earlier cached lookups."), + Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1: diag(6241, DiagnosticCategory.Message, "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241", "Resolution for type reference directive '{0}' was found in cache from location '{1}'."), + Resolving_type_reference_directive_0_containing_file_1: diag(6242, DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_6242", "======== Resolving type reference directive '{0}', containing file '{1}'. ========"), + Interpret_optional_property_types_as_written_rather_than_adding_undefined: diag(6243, DiagnosticCategory.Message, "Interpret_optional_property_types_as_written_rather_than_adding_undefined_6243", "Interpret optional property types as written, rather than adding 'undefined'."), + Modules: diag(6244, DiagnosticCategory.Message, "Modules_6244", "Modules"), + File_Management: diag(6245, DiagnosticCategory.Message, "File_Management_6245", "File Management"), + Emit: diag(6246, DiagnosticCategory.Message, "Emit_6246", "Emit"), + JavaScript_Support: diag(6247, DiagnosticCategory.Message, "JavaScript_Support_6247", "JavaScript Support"), + Type_Checking: diag(6248, DiagnosticCategory.Message, "Type_Checking_6248", "Type Checking"), + Editor_Support: diag(6249, DiagnosticCategory.Message, "Editor_Support_6249", "Editor Support"), + Watch_and_Build_Modes: diag(6250, DiagnosticCategory.Message, "Watch_and_Build_Modes_6250", "Watch and Build Modes"), + Compiler_Diagnostics: diag(6251, DiagnosticCategory.Message, "Compiler_Diagnostics_6251", "Compiler Diagnostics"), + Interop_Constraints: diag(6252, DiagnosticCategory.Message, "Interop_Constraints_6252", "Interop Constraints"), + Backwards_Compatibility: diag(6253, DiagnosticCategory.Message, "Backwards_Compatibility_6253", "Backwards Compatibility"), + Language_and_Environment: diag(6254, DiagnosticCategory.Message, "Language_and_Environment_6254", "Language and Environment"), + Projects: diag(6255, DiagnosticCategory.Message, "Projects_6255", "Projects"), + Output_Formatting: diag(6256, DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"), + Completeness: diag(6257, DiagnosticCategory.Message, "Completeness_6257", "Completeness"), + _0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file: diag(6258, DiagnosticCategory.Error, "_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file_6258", "'{0}' should be set inside the 'compilerOptions' object of the config json file"), + Found_1_error_in_1: diag(6259, DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"), + Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, DiagnosticCategory.Message, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"), + Found_0_errors_in_1_files: diag(6261, DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."), + Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."), + Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."), + Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, DiagnosticCategory.Message, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."), + package_json_scope_0_has_no_imports_defined: diag(6273, DiagnosticCategory.Message, "package_json_scope_0_has_no_imports_defined_6273", "package.json scope '{0}' has no imports defined."), + package_json_scope_0_explicitly_maps_specifier_1_to_null: diag(6274, DiagnosticCategory.Message, "package_json_scope_0_explicitly_maps_specifier_1_to_null_6274", "package.json scope '{0}' explicitly maps specifier '{1}' to null."), + package_json_scope_0_has_invalid_type_for_target_of_specifier_1: diag(6275, DiagnosticCategory.Message, "package_json_scope_0_has_invalid_type_for_target_of_specifier_1_6275", "package.json scope '{0}' has invalid type for target of specifier '{1}'"), + Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6276, DiagnosticCategory.Message, "Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6276", "Export specifier '{0}' does not exist in package.json scope at path '{1}'."), + Enable_project_compilation: diag(6302, DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), + Composite_projects_may_not_disable_declaration_emit: diag(6304, DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), + Output_file_0_has_not_been_built_from_source_file_1: diag(6305, DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), + Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), + File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern: diag(6307, DiagnosticCategory.Error, "File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_includ_6307", "File '{0}' is not listed within the file list of project '{1}'. Projects must list all files or use an 'include' pattern."), + Cannot_prepend_project_0_because_it_does_not_have_outFile_set: diag(6308, DiagnosticCategory.Error, "Cannot_prepend_project_0_because_it_does_not_have_outFile_set_6308", "Cannot prepend project '{0}' because it does not have 'outFile' set"), + Output_file_0_from_project_1_does_not_exist: diag(6309, DiagnosticCategory.Error, "Output_file_0_from_project_1_does_not_exist_6309", "Output file '{0}' from project '{1}' does not exist"), + Referenced_project_0_may_not_disable_emit: diag(6310, DiagnosticCategory.Error, "Referenced_project_0_may_not_disable_emit_6310", "Referenced project '{0}' may not disable emit."), + Project_0_is_out_of_date_because_output_1_is_older_than_input_2: diag(6350, DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_1_is_older_than_input_2_6350", "Project '{0}' is out of date because output '{1}' is older than input '{2}'"), + Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2: diag(6351, DiagnosticCategory.Message, "Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2_6351", "Project '{0}' is up to date because newest input '{1}' is older than output '{2}'"), + Project_0_is_out_of_date_because_output_file_1_does_not_exist: diag(6352, DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_file_1_does_not_exist_6352", "Project '{0}' is out of date because output file '{1}' does not exist"), + Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date: diag(6353, DiagnosticCategory.Message, "Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date_6353", "Project '{0}' is out of date because its dependency '{1}' is out of date"), + Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies: diag(6354, DiagnosticCategory.Message, "Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies_6354", "Project '{0}' is up to date with .d.ts files from its dependencies"), + Projects_in_this_build_Colon_0: diag(6355, DiagnosticCategory.Message, "Projects_in_this_build_Colon_0_6355", "Projects in this build: {0}"), + A_non_dry_build_would_delete_the_following_files_Colon_0: diag(6356, DiagnosticCategory.Message, "A_non_dry_build_would_delete_the_following_files_Colon_0_6356", "A non-dry build would delete the following files: {0}"), + A_non_dry_build_would_build_project_0: diag(6357, DiagnosticCategory.Message, "A_non_dry_build_would_build_project_0_6357", "A non-dry build would build project '{0}'"), + Building_project_0: diag(6358, DiagnosticCategory.Message, "Building_project_0_6358", "Building project '{0}'..."), + Updating_output_timestamps_of_project_0: diag(6359, DiagnosticCategory.Message, "Updating_output_timestamps_of_project_0_6359", "Updating output timestamps of project '{0}'..."), + Project_0_is_up_to_date: diag(6361, DiagnosticCategory.Message, "Project_0_is_up_to_date_6361", "Project '{0}' is up to date"), + Skipping_build_of_project_0_because_its_dependency_1_has_errors: diag(6362, DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_has_errors_6362", "Skipping build of project '{0}' because its dependency '{1}' has errors"), + Project_0_can_t_be_built_because_its_dependency_1_has_errors: diag(6363, DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_has_errors_6363", "Project '{0}' can't be built because its dependency '{1}' has errors"), + Build_one_or_more_projects_and_their_dependencies_if_out_of_date: diag(6364, DiagnosticCategory.Message, "Build_one_or_more_projects_and_their_dependencies_if_out_of_date_6364", "Build one or more projects and their dependencies, if out of date"), + Delete_the_outputs_of_all_projects: diag(6365, DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects."), + Show_what_would_be_built_or_deleted_if_specified_with_clean: diag(6367, DiagnosticCategory.Message, "Show_what_would_be_built_or_deleted_if_specified_with_clean_6367", "Show what would be built (or deleted, if specified with '--clean')"), + Option_build_must_be_the_first_command_line_argument: diag(6369, DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), + Options_0_and_1_cannot_be_combined: diag(6370, DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), + Updating_unchanged_output_timestamps_of_project_0: diag(6371, DiagnosticCategory.Message, "Updating_unchanged_output_timestamps_of_project_0_6371", "Updating unchanged output timestamps of project '{0}'..."), + Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed: diag(6372, DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed_6372", "Project '{0}' is out of date because output of its dependency '{1}' has changed"), + Updating_output_of_project_0: diag(6373, DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."), + A_non_dry_build_would_update_timestamps_for_output_of_project_0: diag(6374, DiagnosticCategory.Message, "A_non_dry_build_would_update_timestamps_for_output_of_project_0_6374", "A non-dry build would update timestamps for output of project '{0}'"), + A_non_dry_build_would_update_output_of_project_0: diag(6375, DiagnosticCategory.Message, "A_non_dry_build_would_update_output_of_project_0_6375", "A non-dry build would update output of project '{0}'"), + Cannot_update_output_of_project_0_because_there_was_error_reading_file_1: diag(6376, DiagnosticCategory.Message, "Cannot_update_output_of_project_0_because_there_was_error_reading_file_1_6376", "Cannot update output of project '{0}' because there was error reading file '{1}'"), + Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1: diag(6377, DiagnosticCategory.Error, "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377", "Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'"), + Composite_projects_may_not_disable_incremental_compilation: diag(6379, DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), + Specify_file_to_store_incremental_compilation_information: diag(6380, DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), + Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), + Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6384, DiagnosticCategory.Message, "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384", "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it."), + _0_is_deprecated: diag(6385, DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), + The_signature_0_of_1_is_deprecated: diag(6387, DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + Project_0_is_being_forcibly_rebuilt: diag(6388, DiagnosticCategory.Message, "Project_0_is_being_forcibly_rebuilt_6388", "Project '{0}' is being forcibly rebuilt"), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved: diag(6389, DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved_6389", "Reusing resolution of module '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6390, DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6390", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6391, DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6391", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved: diag(6392, DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved_6392", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6393, DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6393", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6394, DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6394", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6395, DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved_6395", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted: diag(6399, DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes were not emitted"), + Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs to update timestamps of output files that are older than input files"), + Project_0_is_out_of_date_because_there_was_error_reading_file_1: diag(6401, DiagnosticCategory.Message, "Project_0_is_out_of_date_because_there_was_error_reading_file_1_6401", "Project '{0}' is out of date because there was error reading file '{1}'"), + Resolving_in_0_mode_with_conditions_1: diag(6402, DiagnosticCategory.Message, "Resolving_in_0_mode_with_conditions_1_6402", "Resolving in {0} mode with conditions {1}."), + Matched_0_condition_1: diag(6403, DiagnosticCategory.Message, "Matched_0_condition_1_6403", "Matched '{0}' condition '{1}'."), + Using_0_subpath_1_with_target_2: diag(6404, DiagnosticCategory.Message, "Using_0_subpath_1_with_target_2_6404", "Using '{0}' subpath '{1}' with target '{2}'."), + Saw_non_matching_condition_0: diag(6405, DiagnosticCategory.Message, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."), + Project_0_is_out_of_date_because_buildinfo_file_1_indicates_there_is_change_in_compilerOptions: diag(6406, DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_there_is_change_in_compilerOptions_6406", "Project '{0}' is out of date because buildinfo file '{1}' indicates there is change in compilerOptions"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), + The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), + Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), + File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), + Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."), + Consider_adding_a_declare_modifier_to_this_class: diag(6506, DiagnosticCategory.Message, "Consider_adding_a_declare_modifier_to_this_class_6506", "Consider adding a 'declare' modifier to this class."), + Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files: diag(6600, DiagnosticCategory.Message, "Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these__6600", "Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files."), + Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export: diag(6601, DiagnosticCategory.Message, "Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export_6601", "Allow 'import x from y' when a module doesn't have a default export."), + Allow_accessing_UMD_globals_from_modules: diag(6602, DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_6602", "Allow accessing UMD globals from modules."), + Disable_error_reporting_for_unreachable_code: diag(6603, DiagnosticCategory.Message, "Disable_error_reporting_for_unreachable_code_6603", "Disable error reporting for unreachable code."), + Disable_error_reporting_for_unused_labels: diag(6604, DiagnosticCategory.Message, "Disable_error_reporting_for_unused_labels_6604", "Disable error reporting for unused labels."), + Ensure_use_strict_is_always_emitted: diag(6605, DiagnosticCategory.Message, "Ensure_use_strict_is_always_emitted_6605", "Ensure 'use strict' is always emitted."), + Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6606, DiagnosticCategory.Message, "Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_wi_6606", "Have recompiles in projects that use 'incremental' and 'watch' mode assume that changes within a file will only affect files directly depending on it."), + Specify_the_base_directory_to_resolve_non_relative_module_names: diag(6607, DiagnosticCategory.Message, "Specify_the_base_directory_to_resolve_non_relative_module_names_6607", "Specify the base directory to resolve non-relative module names."), + No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files: diag(6608, DiagnosticCategory.Message, "No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files_6608", "No longer supported. In early versions, manually set the text encoding for reading files."), + Enable_error_reporting_in_type_checked_JavaScript_files: diag(6609, DiagnosticCategory.Message, "Enable_error_reporting_in_type_checked_JavaScript_files_6609", "Enable error reporting in type-checked JavaScript files."), + Enable_constraints_that_allow_a_TypeScript_project_to_be_used_with_project_references: diag(6611, DiagnosticCategory.Message, "Enable_constraints_that_allow_a_TypeScript_project_to_be_used_with_project_references_6611", "Enable constraints that allow a TypeScript project to be used with project references."), + Generate_d_ts_files_from_TypeScript_and_JavaScript_files_in_your_project: diag(6612, DiagnosticCategory.Message, "Generate_d_ts_files_from_TypeScript_and_JavaScript_files_in_your_project_6612", "Generate .d.ts files from TypeScript and JavaScript files in your project."), + Specify_the_output_directory_for_generated_declaration_files: diag(6613, DiagnosticCategory.Message, "Specify_the_output_directory_for_generated_declaration_files_6613", "Specify the output directory for generated declaration files."), + Create_sourcemaps_for_d_ts_files: diag(6614, DiagnosticCategory.Message, "Create_sourcemaps_for_d_ts_files_6614", "Create sourcemaps for d.ts files."), + Output_compiler_performance_information_after_building: diag(6615, DiagnosticCategory.Message, "Output_compiler_performance_information_after_building_6615", "Output compiler performance information after building."), + Disables_inference_for_type_acquisition_by_looking_at_filenames_in_a_project: diag(6616, DiagnosticCategory.Message, "Disables_inference_for_type_acquisition_by_looking_at_filenames_in_a_project_6616", "Disables inference for type acquisition by looking at filenames in a project."), + Reduce_the_number_of_projects_loaded_automatically_by_TypeScript: diag(6617, DiagnosticCategory.Message, "Reduce_the_number_of_projects_loaded_automatically_by_TypeScript_6617", "Reduce the number of projects loaded automatically by TypeScript."), + Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server: diag(6618, DiagnosticCategory.Message, "Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server_6618", "Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server."), + Opt_a_project_out_of_multi_project_reference_checking_when_editing: diag(6619, DiagnosticCategory.Message, "Opt_a_project_out_of_multi_project_reference_checking_when_editing_6619", "Opt a project out of multi-project reference checking when editing."), + Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects: diag(6620, DiagnosticCategory.Message, "Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects_6620", "Disable preferring source files instead of declaration files when referencing composite projects."), + Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration: diag(6621, DiagnosticCategory.Message, "Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration_6621", "Emit more compliant, but verbose and less performant JavaScript for iteration."), + Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: diag(6622, DiagnosticCategory.Message, "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6622", "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files."), + Only_output_d_ts_files_and_not_JavaScript_files: diag(6623, DiagnosticCategory.Message, "Only_output_d_ts_files_and_not_JavaScript_files_6623", "Only output d.ts files and not JavaScript files."), + Emit_design_type_metadata_for_decorated_declarations_in_source_files: diag(6624, DiagnosticCategory.Message, "Emit_design_type_metadata_for_decorated_declarations_in_source_files_6624", "Emit design-type metadata for decorated declarations in source files."), + Disable_the_type_acquisition_for_JavaScript_projects: diag(6625, DiagnosticCategory.Message, "Disable_the_type_acquisition_for_JavaScript_projects_6625", "Disable the type acquisition for JavaScript projects"), + Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility: diag(6626, DiagnosticCategory.Message, "Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheti_6626", "Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility."), + Filters_results_from_the_include_option: diag(6627, DiagnosticCategory.Message, "Filters_results_from_the_include_option_6627", "Filters results from the `include` option."), + Remove_a_list_of_directories_from_the_watch_process: diag(6628, DiagnosticCategory.Message, "Remove_a_list_of_directories_from_the_watch_process_6628", "Remove a list of directories from the watch process."), + Remove_a_list_of_files_from_the_watch_mode_s_processing: diag(6629, DiagnosticCategory.Message, "Remove_a_list_of_files_from_the_watch_mode_s_processing_6629", "Remove a list of files from the watch mode's processing."), + Enable_experimental_support_for_TC39_stage_2_draft_decorators: diag(6630, DiagnosticCategory.Message, "Enable_experimental_support_for_TC39_stage_2_draft_decorators_6630", "Enable experimental support for TC39 stage 2 draft decorators."), + Print_files_read_during_the_compilation_including_why_it_was_included: diag(6631, DiagnosticCategory.Message, "Print_files_read_during_the_compilation_including_why_it_was_included_6631", "Print files read during the compilation including why it was included."), + Output_more_detailed_compiler_performance_information_after_building: diag(6632, DiagnosticCategory.Message, "Output_more_detailed_compiler_performance_information_after_building_6632", "Output more detailed compiler performance information after building."), + Specify_one_or_more_path_or_node_module_references_to_base_configuration_files_from_which_settings_are_inherited: diag(6633, DiagnosticCategory.Message, "Specify_one_or_more_path_or_node_module_references_to_base_configuration_files_from_which_settings_a_6633", "Specify one or more path or node module references to base configuration files from which settings are inherited."), + Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers: diag(6634, DiagnosticCategory.Message, "Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers_6634", "Specify what approach the watcher should use if the system runs out of native file watchers."), + Include_a_list_of_files_This_does_not_support_glob_patterns_as_opposed_to_include: diag(6635, DiagnosticCategory.Message, "Include_a_list_of_files_This_does_not_support_glob_patterns_as_opposed_to_include_6635", "Include a list of files. This does not support glob patterns, as opposed to `include`."), + Build_all_projects_including_those_that_appear_to_be_up_to_date: diag(6636, DiagnosticCategory.Message, "Build_all_projects_including_those_that_appear_to_be_up_to_date_6636", "Build all projects, including those that appear to be up to date."), + Ensure_that_casing_is_correct_in_imports: diag(6637, DiagnosticCategory.Message, "Ensure_that_casing_is_correct_in_imports_6637", "Ensure that casing is correct in imports."), + Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging: diag(6638, DiagnosticCategory.Message, "Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging_6638", "Emit a v8 CPU profile of the compiler run for debugging."), + Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file: diag(6639, DiagnosticCategory.Message, "Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file_6639", "Allow importing helper functions from tslib once per project, instead of including them per-file."), + Specify_a_list_of_glob_patterns_that_match_files_to_be_included_in_compilation: diag(6641, DiagnosticCategory.Message, "Specify_a_list_of_glob_patterns_that_match_files_to_be_included_in_compilation_6641", "Specify a list of glob patterns that match files to be included in compilation."), + Save_tsbuildinfo_files_to_allow_for_incremental_compilation_of_projects: diag(6642, DiagnosticCategory.Message, "Save_tsbuildinfo_files_to_allow_for_incremental_compilation_of_projects_6642", "Save .tsbuildinfo files to allow for incremental compilation of projects."), + Include_sourcemap_files_inside_the_emitted_JavaScript: diag(6643, DiagnosticCategory.Message, "Include_sourcemap_files_inside_the_emitted_JavaScript_6643", "Include sourcemap files inside the emitted JavaScript."), + Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript: diag(6644, DiagnosticCategory.Message, "Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript_6644", "Include source code in the sourcemaps inside the emitted JavaScript."), + Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports: diag(6645, DiagnosticCategory.Message, "Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports_6645", "Ensure that each file can be safely transpiled without relying on other imports."), + Specify_what_JSX_code_is_generated: diag(6646, DiagnosticCategory.Message, "Specify_what_JSX_code_is_generated_6646", "Specify what JSX code is generated."), + Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h: diag(6647, DiagnosticCategory.Message, "Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h_6647", "Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'."), + Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment: diag(6648, DiagnosticCategory.Message, "Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragme_6648", "Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'."), + Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk: diag(6649, DiagnosticCategory.Message, "Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Ast_6649", "Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'."), + Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option: diag(6650, DiagnosticCategory.Message, "Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option_6650", "Make keyof only return strings instead of string, numbers or symbols. Legacy option."), + Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment: diag(6651, DiagnosticCategory.Message, "Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment_6651", "Specify a set of bundled library declaration files that describe the target runtime environment."), + Print_the_names_of_emitted_files_after_a_compilation: diag(6652, DiagnosticCategory.Message, "Print_the_names_of_emitted_files_after_a_compilation_6652", "Print the names of emitted files after a compilation."), + Print_all_of_the_files_read_during_the_compilation: diag(6653, DiagnosticCategory.Message, "Print_all_of_the_files_read_during_the_compilation_6653", "Print all of the files read during the compilation."), + Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit: diag(6654, DiagnosticCategory.Message, "Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit_6654", "Set the language of the messaging from TypeScript. This does not affect emit."), + Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: diag(6655, DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6655", "Specify the location where debugger should locate map files instead of generated locations."), + Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicable_with_allowJs: diag(6656, DiagnosticCategory.Message, "Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicabl_6656", "Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'."), + Specify_what_module_code_is_generated: diag(6657, DiagnosticCategory.Message, "Specify_what_module_code_is_generated_6657", "Specify what module code is generated."), + Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier: diag(6658, DiagnosticCategory.Message, "Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier_6658", "Specify how TypeScript looks up a file from a given module specifier."), + Set_the_newline_character_for_emitting_files: diag(6659, DiagnosticCategory.Message, "Set_the_newline_character_for_emitting_files_6659", "Set the newline character for emitting files."), + Disable_emitting_files_from_a_compilation: diag(6660, DiagnosticCategory.Message, "Disable_emitting_files_from_a_compilation_6660", "Disable emitting files from a compilation."), + Disable_generating_custom_helper_functions_like_extends_in_compiled_output: diag(6661, DiagnosticCategory.Message, "Disable_generating_custom_helper_functions_like_extends_in_compiled_output_6661", "Disable generating custom helper functions like '__extends' in compiled output."), + Disable_emitting_files_if_any_type_checking_errors_are_reported: diag(6662, DiagnosticCategory.Message, "Disable_emitting_files_if_any_type_checking_errors_are_reported_6662", "Disable emitting files if any type checking errors are reported."), + Disable_truncating_types_in_error_messages: diag(6663, DiagnosticCategory.Message, "Disable_truncating_types_in_error_messages_6663", "Disable truncating types in error messages."), + Enable_error_reporting_for_fallthrough_cases_in_switch_statements: diag(6664, DiagnosticCategory.Message, "Enable_error_reporting_for_fallthrough_cases_in_switch_statements_6664", "Enable error reporting for fallthrough cases in switch statements."), + Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type: diag(6665, DiagnosticCategory.Message, "Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type_6665", "Enable error reporting for expressions and declarations with an implied 'any' type."), + Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6666, DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6666", "Ensure overriding members in derived classes are marked with an override modifier."), + Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function: diag(6667, DiagnosticCategory.Message, "Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function_6667", "Enable error reporting for codepaths that do not explicitly return in a function."), + Enable_error_reporting_when_this_is_given_the_type_any: diag(6668, DiagnosticCategory.Message, "Enable_error_reporting_when_this_is_given_the_type_any_6668", "Enable error reporting when 'this' is given the type 'any'."), + Disable_adding_use_strict_directives_in_emitted_JavaScript_files: diag(6669, DiagnosticCategory.Message, "Disable_adding_use_strict_directives_in_emitted_JavaScript_files_6669", "Disable adding 'use strict' directives in emitted JavaScript files."), + Disable_including_any_library_files_including_the_default_lib_d_ts: diag(6670, DiagnosticCategory.Message, "Disable_including_any_library_files_including_the_default_lib_d_ts_6670", "Disable including any library files, including the default lib.d.ts."), + Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type: diag(6671, DiagnosticCategory.Message, "Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type_6671", "Enforces using indexed accessors for keys declared using an indexed type."), + Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add_to_a_project: diag(6672, DiagnosticCategory.Message, "Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add__6672", "Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project."), + Disable_strict_checking_of_generic_signatures_in_function_types: diag(6673, DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6673", "Disable strict checking of generic signatures in function types."), + Add_undefined_to_a_type_when_accessed_using_an_index: diag(6674, DiagnosticCategory.Message, "Add_undefined_to_a_type_when_accessed_using_an_index_6674", "Add 'undefined' to a type when accessed using an index."), + Enable_error_reporting_when_local_variables_aren_t_read: diag(6675, DiagnosticCategory.Message, "Enable_error_reporting_when_local_variables_aren_t_read_6675", "Enable error reporting when local variables aren't read."), + Raise_an_error_when_a_function_parameter_isn_t_read: diag(6676, DiagnosticCategory.Message, "Raise_an_error_when_a_function_parameter_isn_t_read_6676", "Raise an error when a function parameter isn't read."), + Deprecated_setting_Use_outFile_instead: diag(6677, DiagnosticCategory.Message, "Deprecated_setting_Use_outFile_instead_6677", "Deprecated setting. Use 'outFile' instead."), + Specify_an_output_folder_for_all_emitted_files: diag(6678, DiagnosticCategory.Message, "Specify_an_output_folder_for_all_emitted_files_6678", "Specify an output folder for all emitted files."), + Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output: diag(6679, DiagnosticCategory.Message, "Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designa_6679", "Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output."), + Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations: diag(6680, DiagnosticCategory.Message, "Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations_6680", "Specify a set of entries that re-map imports to additional lookup locations."), + Specify_a_list_of_language_service_plugins_to_include: diag(6681, DiagnosticCategory.Message, "Specify_a_list_of_language_service_plugins_to_include_6681", "Specify a list of language service plugins to include."), + Disable_erasing_const_enum_declarations_in_generated_code: diag(6682, DiagnosticCategory.Message, "Disable_erasing_const_enum_declarations_in_generated_code_6682", "Disable erasing 'const enum' declarations in generated code."), + Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node: diag(6683, DiagnosticCategory.Message, "Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node_6683", "Disable resolving symlinks to their realpath. This correlates to the same flag in node."), + Disable_wiping_the_console_in_watch_mode: diag(6684, DiagnosticCategory.Message, "Disable_wiping_the_console_in_watch_mode_6684", "Disable wiping the console in watch mode."), + Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read: diag(6685, DiagnosticCategory.Message, "Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read_6685", "Enable color and formatting in TypeScript's output to make compiler errors easier to read."), + Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit: diag(6686, DiagnosticCategory.Message, "Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit_6686", "Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit."), + Specify_an_array_of_objects_that_specify_paths_for_projects_Used_in_project_references: diag(6687, DiagnosticCategory.Message, "Specify_an_array_of_objects_that_specify_paths_for_projects_Used_in_project_references_6687", "Specify an array of objects that specify paths for projects. Used in project references."), + Disable_emitting_comments: diag(6688, DiagnosticCategory.Message, "Disable_emitting_comments_6688", "Disable emitting comments."), + Enable_importing_json_files: diag(6689, DiagnosticCategory.Message, "Enable_importing_json_files_6689", "Enable importing .json files."), + Specify_the_root_folder_within_your_source_files: diag(6690, DiagnosticCategory.Message, "Specify_the_root_folder_within_your_source_files_6690", "Specify the root folder within your source files."), + Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules: diag(6691, DiagnosticCategory.Message, "Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules_6691", "Allow multiple folders to be treated as one when resolving modules."), + Skip_type_checking_d_ts_files_that_are_included_with_TypeScript: diag(6692, DiagnosticCategory.Message, "Skip_type_checking_d_ts_files_that_are_included_with_TypeScript_6692", "Skip type checking .d.ts files that are included with TypeScript."), + Skip_type_checking_all_d_ts_files: diag(6693, DiagnosticCategory.Message, "Skip_type_checking_all_d_ts_files_6693", "Skip type checking all .d.ts files."), + Create_source_map_files_for_emitted_JavaScript_files: diag(6694, DiagnosticCategory.Message, "Create_source_map_files_for_emitted_JavaScript_files_6694", "Create source map files for emitted JavaScript files."), + Specify_the_root_path_for_debuggers_to_find_the_reference_source_code: diag(6695, DiagnosticCategory.Message, "Specify_the_root_path_for_debuggers_to_find_the_reference_source_code_6695", "Specify the root path for debuggers to find the reference source code."), + Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function: diag(6697, DiagnosticCategory.Message, "Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function_6697", "Check that the arguments for 'bind', 'call', and 'apply' methods match the original function."), + When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible: diag(6698, DiagnosticCategory.Message, "When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible_6698", "When assigning functions, check to ensure parameters and the return values are subtype-compatible."), + When_type_checking_take_into_account_null_and_undefined: diag(6699, DiagnosticCategory.Message, "When_type_checking_take_into_account_null_and_undefined_6699", "When type checking, take into account 'null' and 'undefined'."), + Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor: diag(6700, DiagnosticCategory.Message, "Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor_6700", "Check for class properties that are declared but not set in the constructor."), + Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments: diag(6701, DiagnosticCategory.Message, "Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments_6701", "Disable emitting declarations that have '@internal' in their JSDoc comments."), + Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals: diag(6702, DiagnosticCategory.Message, "Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals_6702", "Disable reporting of excess property errors during the creation of object literals."), + Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures: diag(6703, DiagnosticCategory.Message, "Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures_6703", "Suppress 'noImplicitAny' errors when indexing objects that lack index signatures."), + Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6704, DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6704", "Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively."), + Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations: diag(6705, DiagnosticCategory.Message, "Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declaratio_6705", "Set the JavaScript language version for emitted JavaScript and include compatible library declarations."), + Log_paths_used_during_the_moduleResolution_process: diag(6706, DiagnosticCategory.Message, "Log_paths_used_during_the_moduleResolution_process_6706", "Log paths used during the 'moduleResolution' process."), + Specify_the_path_to_tsbuildinfo_incremental_compilation_file: diag(6707, DiagnosticCategory.Message, "Specify_the_path_to_tsbuildinfo_incremental_compilation_file_6707", "Specify the path to .tsbuildinfo incremental compilation file."), + Specify_options_for_automatic_acquisition_of_declaration_files: diag(6709, DiagnosticCategory.Message, "Specify_options_for_automatic_acquisition_of_declaration_files_6709", "Specify options for automatic acquisition of declaration files."), + Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types: diag(6710, DiagnosticCategory.Message, "Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types_6710", "Specify multiple folders that act like './node_modules/@types'."), + Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file: diag(6711, DiagnosticCategory.Message, "Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file_6711", "Specify type package names to be included without being referenced in a source file."), + Emit_ECMAScript_standard_compliant_class_fields: diag(6712, DiagnosticCategory.Message, "Emit_ECMAScript_standard_compliant_class_fields_6712", "Emit ECMAScript-standard-compliant class fields."), + Enable_verbose_logging: diag(6713, DiagnosticCategory.Message, "Enable_verbose_logging_6713", "Enable verbose logging."), + Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality: diag(6714, DiagnosticCategory.Message, "Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality_6714", "Specify how directories are watched on systems that lack recursive file-watching functionality."), + Specify_how_the_TypeScript_watch_mode_works: diag(6715, DiagnosticCategory.Message, "Specify_how_the_TypeScript_watch_mode_works_6715", "Specify how the TypeScript watch mode works."), + Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6717, DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6717", "Require undeclared properties from index signatures to use element accesses."), + Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."), + Ensure_that_each_file_can_have_declaration_emit_generated_without_type_information: diag(6719, DiagnosticCategory.Message, "Ensure_that_each_file_can_have_declaration_emit_generated_without_type_information_6719", "Ensure that each file can have declaration emit generated without type information"), + Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, DiagnosticCategory.Message, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."), + one_of_Colon: diag(6900, DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"), + one_or_more_Colon: diag(6901, DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"), + type_Colon: diag(6902, DiagnosticCategory.Message, "type_Colon_6902", "type:"), + default_Colon: diag(6903, DiagnosticCategory.Message, "default_Colon_6903", "default:"), + module_system_or_esModuleInterop: diag(6904, DiagnosticCategory.Message, "module_system_or_esModuleInterop_6904", "module === \"system\" or esModuleInterop"), + false_unless_strict_is_set: diag(6905, DiagnosticCategory.Message, "false_unless_strict_is_set_6905", "`false`, unless `strict` is set"), + false_unless_composite_is_set: diag(6906, DiagnosticCategory.Message, "false_unless_composite_is_set_6906", "`false`, unless `composite` is set"), + node_modules_bower_components_jspm_packages_plus_the_value_of_outDir_if_one_is_specified: diag(6907, DiagnosticCategory.Message, "node_modules_bower_components_jspm_packages_plus_the_value_of_outDir_if_one_is_specified_6907", "`[\"node_modules\", \"bower_components\", \"jspm_packages\"]`, plus the value of `outDir` if one is specified."), + if_files_is_specified_otherwise_Asterisk_Asterisk_Slash_Asterisk: diag(6908, DiagnosticCategory.Message, "if_files_is_specified_otherwise_Asterisk_Asterisk_Slash_Asterisk_6908", "`[]` if `files` is specified, otherwise `[\"**/*\"]`"), + true_if_composite_false_otherwise: diag(6909, DiagnosticCategory.Message, "true_if_composite_false_otherwise_6909", "`true` if `composite`, `false` otherwise"), + module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node: diag(69010, DiagnosticCategory.Message, "module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node_69010", "module === `AMD` or `UMD` or `System` or `ES6`, then `Classic`, Otherwise `Node`"), + Computed_from_the_list_of_input_files: diag(6911, DiagnosticCategory.Message, "Computed_from_the_list_of_input_files_6911", "Computed from the list of input files"), + Platform_specific: diag(6912, DiagnosticCategory.Message, "Platform_specific_6912", "Platform specific"), + You_can_learn_about_all_of_the_compiler_options_at_0: diag(6913, DiagnosticCategory.Message, "You_can_learn_about_all_of_the_compiler_options_at_0_6913", "You can learn about all of the compiler options at {0}"), + Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon: diag(6914, DiagnosticCategory.Message, "Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_conf_6914", "Including --watch, -w will start watching the current project for the file changes. Once set, you can config watch mode with:"), + Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0: diag(6915, DiagnosticCategory.Message, "Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_tr_6915", "Using --build, -b will make tsc behave more like a build orchestrator than a compiler. This is used to trigger building composite projects which you can learn more about at {0}"), + COMMON_COMMANDS: diag(6916, DiagnosticCategory.Message, "COMMON_COMMANDS_6916", "COMMON COMMANDS"), + ALL_COMPILER_OPTIONS: diag(6917, DiagnosticCategory.Message, "ALL_COMPILER_OPTIONS_6917", "ALL COMPILER OPTIONS"), + WATCH_OPTIONS: diag(6918, DiagnosticCategory.Message, "WATCH_OPTIONS_6918", "WATCH OPTIONS"), + BUILD_OPTIONS: diag(6919, DiagnosticCategory.Message, "BUILD_OPTIONS_6919", "BUILD OPTIONS"), + COMMON_COMPILER_OPTIONS: diag(6920, DiagnosticCategory.Message, "COMMON_COMPILER_OPTIONS_6920", "COMMON COMPILER OPTIONS"), + COMMAND_LINE_FLAGS: diag(6921, DiagnosticCategory.Message, "COMMAND_LINE_FLAGS_6921", "COMMAND LINE FLAGS"), + tsc_Colon_The_TypeScript_Compiler: diag(6922, DiagnosticCategory.Message, "tsc_Colon_The_TypeScript_Compiler_6922", "tsc: The TypeScript Compiler"), + Compiles_the_current_project_tsconfig_json_in_the_working_directory: diag(6923, DiagnosticCategory.Message, "Compiles_the_current_project_tsconfig_json_in_the_working_directory_6923", "Compiles the current project (tsconfig.json in the working directory.)"), + Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options: diag(6924, DiagnosticCategory.Message, "Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options_6924", "Ignoring tsconfig.json, compiles the specified files with default compiler options."), + Build_a_composite_project_in_the_working_directory: diag(6925, DiagnosticCategory.Message, "Build_a_composite_project_in_the_working_directory_6925", "Build a composite project in the working directory."), + Creates_a_tsconfig_json_with_the_recommended_settings_in_the_working_directory: diag(6926, DiagnosticCategory.Message, "Creates_a_tsconfig_json_with_the_recommended_settings_in_the_working_directory_6926", "Creates a tsconfig.json with the recommended settings in the working directory."), + Compiles_the_TypeScript_project_located_at_the_specified_path: diag(6927, DiagnosticCategory.Message, "Compiles_the_TypeScript_project_located_at_the_specified_path_6927", "Compiles the TypeScript project located at the specified path."), + An_expanded_version_of_this_information_showing_all_possible_compiler_options: diag(6928, DiagnosticCategory.Message, "An_expanded_version_of_this_information_showing_all_possible_compiler_options_6928", "An expanded version of this information, showing all possible compiler options"), + Compiles_the_current_project_with_additional_settings: diag(6929, DiagnosticCategory.Message, "Compiles_the_current_project_with_additional_settings_6929", "Compiles the current project, with additional settings."), + true_for_ES2022_and_above_including_ESNext: diag(6930, DiagnosticCategory.Message, "true_for_ES2022_and_above_including_ESNext_6930", "`true` for ES2022 and above, including ESNext."), + List_of_file_name_suffixes_to_search_when_resolving_a_module: diag(6931, DiagnosticCategory.Error, "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931", "List of file name suffixes to search when resolving a module."), + Variable_0_implicitly_has_an_1_type: diag(7005, DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), + Parameter_0_implicitly_has_an_1_type: diag(7006, DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), + Member_0_implicitly_has_an_1_type: diag(7008, DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), + new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: diag(7009, DiagnosticCategory.Error, "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009", "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type."), + _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: diag(7010, DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type."), + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7011, DiagnosticCategory.Error, "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type."), + Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7013, DiagnosticCategory.Error, "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type."), + Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7014, DiagnosticCategory.Error, "Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7014", "Function type, which lacks return-type annotation, implicitly has an '{0}' return type."), + Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: diag(7015, DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", "Element implicitly has an 'any' type because index expression is not of type 'number'."), + Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: diag(7016, DiagnosticCategory.Error, "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type."), + Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: diag(7017, DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", "Element implicitly has an 'any' type because type '{0}' has no index signature."), + Object_literal_s_property_0_implicitly_has_an_1_type: diag(7018, DiagnosticCategory.Error, "Object_literal_s_property_0_implicitly_has_an_1_type_7018", "Object literal's property '{0}' implicitly has an '{1}' type."), + Rest_parameter_0_implicitly_has_an_any_type: diag(7019, DiagnosticCategory.Error, "Rest_parameter_0_implicitly_has_an_any_type_7019", "Rest parameter '{0}' implicitly has an 'any[]' type."), + Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7020, DiagnosticCategory.Error, "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", "Call signature, which lacks return-type annotation, implicitly has an 'any' return type."), + _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: diag(7022, DiagnosticCategory.Error, "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022", "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer."), + _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: diag(7023, DiagnosticCategory.Error, "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions."), + Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: diag(7024, DiagnosticCategory.Error, "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions."), + Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation: diag(7025, DiagnosticCategory.Error, "Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_retu_7025", "Generator implicitly has yield type '{0}' because it does not yield any values. Consider supplying a return type annotation."), + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: diag(7026, DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists."), + Unreachable_code_detected: diag(7027, DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", /*reportsUnnecessary*/ true), + Unused_label: diag(7028, DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", /*reportsUnnecessary*/ true), + Fallthrough_case_in_switch: diag(7029, DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."), + Not_all_code_paths_return_a_value: diag(7030, DiagnosticCategory.Error, "Not_all_code_paths_return_a_value_7030", "Not all code paths return a value."), + Binding_element_0_implicitly_has_an_1_type: diag(7031, DiagnosticCategory.Error, "Binding_element_0_implicitly_has_an_1_type_7031", "Binding element '{0}' implicitly has an '{1}' type."), + Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: diag(7032, DiagnosticCategory.Error, "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation."), + Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: diag(7033, DiagnosticCategory.Error, "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation."), + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: diag(7034, DiagnosticCategory.Error, "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined."), + Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: diag(7035, DiagnosticCategory.Error, "Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare__7035", "Try `npm i --save-dev @types/{1}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`"), + Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0: diag(7036, DiagnosticCategory.Error, "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036", "Dynamic import's specifier must be of type 'string', but here has type '{0}'."), + Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), + Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), + Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'"), + The_containing_arrow_function_captures_the_global_value_of_this: diag(7041, DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_7041", "The containing arrow function captures the global value of 'this'."), + Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), + Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7044, DiagnosticCategory.Suggestion, "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044", "Parameter '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7045, DiagnosticCategory.Suggestion, "Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7045", "Member '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage: diag(7046, DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage_7046", "Variable '{0}' implicitly has type '{1}' in some locations, but a better type may be inferred from usage."), + Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage: diag(7047, DiagnosticCategory.Suggestion, "Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage_7047", "Rest parameter '{0}' implicitly has an 'any[]' type, but a better type may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage: diag(7048, DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage_7048", "Property '{0}' implicitly has type 'any', but a better type for its get accessor may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage: diag(7049, DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage_7049", "Property '{0}' implicitly has type 'any', but a better type for its set accessor may be inferred from usage."), + _0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."), + Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1: diag(7051, DiagnosticCategory.Error, "Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1_7051", "Parameter has a name but no type. Did you mean '{0}: {1}'?"), + Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1: diag(7052, DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1_7052", "Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}'?"), + Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: diag(7053, DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053", "Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'."), + No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1: diag(7054, DiagnosticCategory.Error, "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054", "No index signature with a parameter of type '{0}' was found on type '{1}'."), + _0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type: diag(7055, DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type_7055", "'{0}', which lacks return-type annotation, implicitly has an '{1}' yield type."), + The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed: diag(7056, DiagnosticCategory.Error, "The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_ty_7056", "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."), + yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation: diag(7057, DiagnosticCategory.Error, "yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_t_7057", "'yield' expression implicitly results in an 'any' type because its containing generator lacks a return-type annotation."), + If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1: diag(7058, DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058", "If the '{0}' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module '{1}';`"), + This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."), + This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."), + A_mapped_type_may_not_declare_properties_or_methods: diag(7061, DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."), + You_cannot_rename_this_element: diag(8000, DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), + You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), + import_can_only_be_used_in_TypeScript_files: diag(8002, DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."), + export_can_only_be_used_in_TypeScript_files: diag(8003, DiagnosticCategory.Error, "export_can_only_be_used_in_TypeScript_files_8003", "'export =' can only be used in TypeScript files."), + Type_parameter_declarations_can_only_be_used_in_TypeScript_files: diag(8004, DiagnosticCategory.Error, "Type_parameter_declarations_can_only_be_used_in_TypeScript_files_8004", "Type parameter declarations can only be used in TypeScript files."), + implements_clauses_can_only_be_used_in_TypeScript_files: diag(8005, DiagnosticCategory.Error, "implements_clauses_can_only_be_used_in_TypeScript_files_8005", "'implements' clauses can only be used in TypeScript files."), + _0_declarations_can_only_be_used_in_TypeScript_files: diag(8006, DiagnosticCategory.Error, "_0_declarations_can_only_be_used_in_TypeScript_files_8006", "'{0}' declarations can only be used in TypeScript files."), + Type_aliases_can_only_be_used_in_TypeScript_files: diag(8008, DiagnosticCategory.Error, "Type_aliases_can_only_be_used_in_TypeScript_files_8008", "Type aliases can only be used in TypeScript files."), + The_0_modifier_can_only_be_used_in_TypeScript_files: diag(8009, DiagnosticCategory.Error, "The_0_modifier_can_only_be_used_in_TypeScript_files_8009", "The '{0}' modifier can only be used in TypeScript files."), + Type_annotations_can_only_be_used_in_TypeScript_files: diag(8010, DiagnosticCategory.Error, "Type_annotations_can_only_be_used_in_TypeScript_files_8010", "Type annotations can only be used in TypeScript files."), + Type_arguments_can_only_be_used_in_TypeScript_files: diag(8011, DiagnosticCategory.Error, "Type_arguments_can_only_be_used_in_TypeScript_files_8011", "Type arguments can only be used in TypeScript files."), + Parameter_modifiers_can_only_be_used_in_TypeScript_files: diag(8012, DiagnosticCategory.Error, "Parameter_modifiers_can_only_be_used_in_TypeScript_files_8012", "Parameter modifiers can only be used in TypeScript files."), + Non_null_assertions_can_only_be_used_in_TypeScript_files: diag(8013, DiagnosticCategory.Error, "Non_null_assertions_can_only_be_used_in_TypeScript_files_8013", "Non-null assertions can only be used in TypeScript files."), + Type_assertion_expressions_can_only_be_used_in_TypeScript_files: diag(8016, DiagnosticCategory.Error, "Type_assertion_expressions_can_only_be_used_in_TypeScript_files_8016", "Type assertion expressions can only be used in TypeScript files."), + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: diag(8017, DiagnosticCategory.Error, "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", "Octal literal types must use ES2015 syntax. Use the syntax '{0}'."), + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."), + Report_errors_in_js_files: diag(8019, DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."), + JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, DiagnosticCategory.Error, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."), + JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, DiagnosticCategory.Error, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."), + JSDoc_0_is_not_attached_to_a_class: diag(8022, DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."), + JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."), + JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."), + Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one '@augments' or '@extends' tag."), + Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."), + Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."), + JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."), + JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type: diag(8029, DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_h_8029", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name. It would match 'arguments' if it had an array type."), + The_type_of_a_function_declaration_must_match_the_function_s_signature: diag(8030, DiagnosticCategory.Error, "The_type_of_a_function_declaration_must_match_the_function_s_signature_8030", "The type of a function declaration must match the function's signature."), + You_cannot_rename_a_module_via_a_global_import: diag(8031, DiagnosticCategory.Error, "You_cannot_rename_a_module_via_a_global_import_8031", "You cannot rename a module via a global import."), + Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."), + A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."), + The_tag_was_first_specified_here: diag(8034, DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."), + You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder: diag(8035, DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035", "You cannot rename elements that are defined in a 'node_modules' folder."), + You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."), + Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files: diag(8037, DiagnosticCategory.Error, "Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files_8037", "Type satisfaction expressions can only be used in TypeScript files."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_type_resolution_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9007, DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_type_resolution_An_explicit_type_annotation_may_unblock_decl_9007", "Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit."), + JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), + Expected_corresponding_JSX_closing_tag_for_0: diag(17002, DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), + Cannot_use_JSX_unless_the_jsx_flag_is_provided: diag(17004, DiagnosticCategory.Error, "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", "Cannot use JSX unless the '--jsx' flag is provided."), + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: diag(17005, DiagnosticCategory.Error, "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", "A constructor cannot contain a 'super' call when its class extends 'null'."), + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: diag(17006, DiagnosticCategory.Error, "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses."), + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: diag(17007, DiagnosticCategory.Error, "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses."), + JSX_element_0_has_no_corresponding_closing_tag: diag(17008, DiagnosticCategory.Error, "JSX_element_0_has_no_corresponding_closing_tag_17008", "JSX element '{0}' has no corresponding closing tag."), + super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: diag(17009, DiagnosticCategory.Error, "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", "'super' must be called before accessing 'this' in the constructor of a derived class."), + Unknown_type_acquisition_option_0: diag(17010, DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_17010", "Unknown type acquisition option '{0}'."), + super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: diag(17011, DiagnosticCategory.Error, "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", "'super' must be called before accessing a property of 'super' in the constructor of a derived class."), + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: diag(17012, DiagnosticCategory.Error, "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012", "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?"), + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: diag(17013, DiagnosticCategory.Error, "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor."), + JSX_fragment_has_no_corresponding_closing_tag: diag(17014, DiagnosticCategory.Error, "JSX_fragment_has_no_corresponding_closing_tag_17014", "JSX fragment has no corresponding closing tag."), + Expected_corresponding_closing_tag_for_JSX_fragment: diag(17015, DiagnosticCategory.Error, "Expected_corresponding_closing_tag_for_JSX_fragment_17015", "Expected corresponding closing tag for JSX fragment."), + The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_compiler_option: diag(17016, DiagnosticCategory.Error, "The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_com_17016", "The 'jsxFragmentFactory' compiler option must be provided to use JSX fragments with the 'jsxFactory' compiler option."), + An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments: diag(17017, DiagnosticCategory.Error, "An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments_17017", "An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments."), + Unknown_type_acquisition_option_0_Did_you_mean_1: diag(17018, DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_Did_you_mean_1_17018", "Unknown type acquisition option '{0}'. Did you mean '{1}'?"), + Circularity_detected_while_resolving_configuration_Colon_0: diag(18000, DiagnosticCategory.Error, "Circularity_detected_while_resolving_configuration_Colon_0_18000", "Circularity detected while resolving configuration: {0}"), + The_files_list_in_config_file_0_is_empty: diag(18002, DiagnosticCategory.Error, "The_files_list_in_config_file_0_is_empty_18002", "The 'files' list in config file '{0}' is empty."), + No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: diag(18003, DiagnosticCategory.Error, "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'."), + File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module: diag(80001, DiagnosticCategory.Suggestion, "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001", "File is a CommonJS module; it may be converted to an ES module."), + This_constructor_function_may_be_converted_to_a_class_declaration: diag(80002, DiagnosticCategory.Suggestion, "This_constructor_function_may_be_converted_to_a_class_declaration_80002", "This constructor function may be converted to a class declaration."), + Import_may_be_converted_to_a_default_import: diag(80003, DiagnosticCategory.Suggestion, "Import_may_be_converted_to_a_default_import_80003", "Import may be converted to a default import."), + JSDoc_types_may_be_moved_to_TypeScript_types: diag(80004, DiagnosticCategory.Suggestion, "JSDoc_types_may_be_moved_to_TypeScript_types_80004", "JSDoc types may be moved to TypeScript types."), + require_call_may_be_converted_to_an_import: diag(80005, DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), + This_may_be_converted_to_an_async_function: diag(80006, DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), + await_has_no_effect_on_the_type_of_this_expression: diag(80007, DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), + Add_missing_super_call: diag(90001, DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), + Make_super_call_the_first_statement_in_the_constructor: diag(90002, DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), + Change_extends_to_implements: diag(90003, DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), + Remove_unused_declaration_for_Colon_0: diag(90004, DiagnosticCategory.Message, "Remove_unused_declaration_for_Colon_0_90004", "Remove unused declaration for: '{0}'"), + Remove_import_from_0: diag(90005, DiagnosticCategory.Message, "Remove_import_from_0_90005", "Remove import from '{0}'"), + Implement_interface_0: diag(90006, DiagnosticCategory.Message, "Implement_interface_0_90006", "Implement interface '{0}'"), + Implement_inherited_abstract_class: diag(90007, DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"), + Add_0_to_unresolved_variable: diag(90008, DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"), + Remove_variable_statement: diag(90010, DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"), + Remove_template_tag: diag(90011, DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"), + Remove_type_parameters: diag(90012, DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"), + Import_0_from_1: diag(90013, DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""), + Change_0_to_1: diag(90014, DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"), + Declare_property_0: diag(90016, DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"), + Add_index_signature_for_property_0: diag(90017, DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"), + Disable_checking_for_this_file: diag(90018, DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"), + Ignore_this_error_message: diag(90019, DiagnosticCategory.Message, "Ignore_this_error_message_90019", "Ignore this error message"), + Initialize_property_0_in_the_constructor: diag(90020, DiagnosticCategory.Message, "Initialize_property_0_in_the_constructor_90020", "Initialize property '{0}' in the constructor"), + Initialize_static_property_0: diag(90021, DiagnosticCategory.Message, "Initialize_static_property_0_90021", "Initialize static property '{0}'"), + Change_spelling_to_0: diag(90022, DiagnosticCategory.Message, "Change_spelling_to_0_90022", "Change spelling to '{0}'"), + Declare_method_0: diag(90023, DiagnosticCategory.Message, "Declare_method_0_90023", "Declare method '{0}'"), + Declare_static_method_0: diag(90024, DiagnosticCategory.Message, "Declare_static_method_0_90024", "Declare static method '{0}'"), + Prefix_0_with_an_underscore: diag(90025, DiagnosticCategory.Message, "Prefix_0_with_an_underscore_90025", "Prefix '{0}' with an underscore"), + Rewrite_as_the_indexed_access_type_0: diag(90026, DiagnosticCategory.Message, "Rewrite_as_the_indexed_access_type_0_90026", "Rewrite as the indexed access type '{0}'"), + Declare_static_property_0: diag(90027, DiagnosticCategory.Message, "Declare_static_property_0_90027", "Declare static property '{0}'"), + Call_decorator_expression: diag(90028, DiagnosticCategory.Message, "Call_decorator_expression_90028", "Call decorator expression"), + Add_async_modifier_to_containing_function: diag(90029, DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"), + Replace_infer_0_with_unknown: diag(90030, DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"), + Replace_all_unused_infer_with_unknown: diag(90031, DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"), + Add_parameter_name: diag(90034, DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"), + Declare_private_property_0: diag(90035, DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"), + Replace_0_with_Promise_1: diag(90036, DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"), + Fix_all_incorrect_return_type_of_an_async_functions: diag(90037, DiagnosticCategory.Message, "Fix_all_incorrect_return_type_of_an_async_functions_90037", "Fix all incorrect return type of an async functions"), + Declare_private_method_0: diag(90038, DiagnosticCategory.Message, "Declare_private_method_0_90038", "Declare private method '{0}'"), + Remove_unused_destructuring_declaration: diag(90039, DiagnosticCategory.Message, "Remove_unused_destructuring_declaration_90039", "Remove unused destructuring declaration"), + Remove_unused_declarations_for_Colon_0: diag(90041, DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"), + Declare_a_private_field_named_0: diag(90053, DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), + Includes_imports_of_types_referenced_by_0: diag(90054, DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"), + Remove_type_from_import_declaration_from_0: diag(90055, DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""), + Remove_type_from_import_of_0_from_1: diag(90056, DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""), + Add_import_from_0: diag(90057, DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""), + Update_import_from_0: diag(90058, DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""), + Export_0_from_module_1: diag(90059, DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"), + Export_all_referenced_locals: diag(90060, DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"), + Convert_function_to_an_ES2015_class: diag(95001, DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), + Convert_0_to_1_in_0: diag(95003, DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"), + Extract_to_0_in_1: diag(95004, DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"), + Extract_function: diag(95005, DiagnosticCategory.Message, "Extract_function_95005", "Extract function"), + Extract_constant: diag(95006, DiagnosticCategory.Message, "Extract_constant_95006", "Extract constant"), + Extract_to_0_in_enclosing_scope: diag(95007, DiagnosticCategory.Message, "Extract_to_0_in_enclosing_scope_95007", "Extract to {0} in enclosing scope"), + Extract_to_0_in_1_scope: diag(95008, DiagnosticCategory.Message, "Extract_to_0_in_1_scope_95008", "Extract to {0} in {1} scope"), + Annotate_with_type_from_JSDoc: diag(95009, DiagnosticCategory.Message, "Annotate_with_type_from_JSDoc_95009", "Annotate with type from JSDoc"), + Infer_type_of_0_from_usage: diag(95011, DiagnosticCategory.Message, "Infer_type_of_0_from_usage_95011", "Infer type of '{0}' from usage"), + Infer_parameter_types_from_usage: diag(95012, DiagnosticCategory.Message, "Infer_parameter_types_from_usage_95012", "Infer parameter types from usage"), + Convert_to_default_import: diag(95013, DiagnosticCategory.Message, "Convert_to_default_import_95013", "Convert to default import"), + Install_0: diag(95014, DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"), + Replace_import_with_0: diag(95015, DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."), + Use_synthetic_default_member: diag(95016, DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."), + Convert_to_ES_module: diag(95017, DiagnosticCategory.Message, "Convert_to_ES_module_95017", "Convert to ES module"), + Add_undefined_type_to_property_0: diag(95018, DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"), + Add_initializer_to_property_0: diag(95019, DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"), + Add_definite_assignment_assertion_to_property_0: diag(95020, DiagnosticCategory.Message, "Add_definite_assignment_assertion_to_property_0_95020", "Add definite assignment assertion to property '{0}'"), + Convert_all_type_literals_to_mapped_type: diag(95021, DiagnosticCategory.Message, "Convert_all_type_literals_to_mapped_type_95021", "Convert all type literals to mapped type"), + Add_all_missing_members: diag(95022, DiagnosticCategory.Message, "Add_all_missing_members_95022", "Add all missing members"), + Infer_all_types_from_usage: diag(95023, DiagnosticCategory.Message, "Infer_all_types_from_usage_95023", "Infer all types from usage"), + Delete_all_unused_declarations: diag(95024, DiagnosticCategory.Message, "Delete_all_unused_declarations_95024", "Delete all unused declarations"), + Prefix_all_unused_declarations_with_where_possible: diag(95025, DiagnosticCategory.Message, "Prefix_all_unused_declarations_with_where_possible_95025", "Prefix all unused declarations with '_' where possible"), + Fix_all_detected_spelling_errors: diag(95026, DiagnosticCategory.Message, "Fix_all_detected_spelling_errors_95026", "Fix all detected spelling errors"), + Add_initializers_to_all_uninitialized_properties: diag(95027, DiagnosticCategory.Message, "Add_initializers_to_all_uninitialized_properties_95027", "Add initializers to all uninitialized properties"), + Add_definite_assignment_assertions_to_all_uninitialized_properties: diag(95028, DiagnosticCategory.Message, "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028", "Add definite assignment assertions to all uninitialized properties"), + Add_undefined_type_to_all_uninitialized_properties: diag(95029, DiagnosticCategory.Message, "Add_undefined_type_to_all_uninitialized_properties_95029", "Add undefined type to all uninitialized properties"), + Change_all_jsdoc_style_types_to_TypeScript: diag(95030, DiagnosticCategory.Message, "Change_all_jsdoc_style_types_to_TypeScript_95030", "Change all jsdoc-style types to TypeScript"), + Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types: diag(95031, DiagnosticCategory.Message, "Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types_95031", "Change all jsdoc-style types to TypeScript (and add '| undefined' to nullable types)"), + Implement_all_unimplemented_interfaces: diag(95032, DiagnosticCategory.Message, "Implement_all_unimplemented_interfaces_95032", "Implement all unimplemented interfaces"), + Install_all_missing_types_packages: diag(95033, DiagnosticCategory.Message, "Install_all_missing_types_packages_95033", "Install all missing types packages"), + Rewrite_all_as_indexed_access_types: diag(95034, DiagnosticCategory.Message, "Rewrite_all_as_indexed_access_types_95034", "Rewrite all as indexed access types"), + Convert_all_to_default_imports: diag(95035, DiagnosticCategory.Message, "Convert_all_to_default_imports_95035", "Convert all to default imports"), + Make_all_super_calls_the_first_statement_in_their_constructor: diag(95036, DiagnosticCategory.Message, "Make_all_super_calls_the_first_statement_in_their_constructor_95036", "Make all 'super()' calls the first statement in their constructor"), + Add_qualifier_to_all_unresolved_variables_matching_a_member_name: diag(95037, DiagnosticCategory.Message, "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037", "Add qualifier to all unresolved variables matching a member name"), + Change_all_extended_interfaces_to_implements: diag(95038, DiagnosticCategory.Message, "Change_all_extended_interfaces_to_implements_95038", "Change all extended interfaces to 'implements'"), + Add_all_missing_super_calls: diag(95039, DiagnosticCategory.Message, "Add_all_missing_super_calls_95039", "Add all missing super calls"), + Implement_all_inherited_abstract_classes: diag(95040, DiagnosticCategory.Message, "Implement_all_inherited_abstract_classes_95040", "Implement all inherited abstract classes"), + Add_all_missing_async_modifiers: diag(95041, DiagnosticCategory.Message, "Add_all_missing_async_modifiers_95041", "Add all missing 'async' modifiers"), + Add_ts_ignore_to_all_error_messages: diag(95042, DiagnosticCategory.Message, "Add_ts_ignore_to_all_error_messages_95042", "Add '@ts-ignore' to all error messages"), + Annotate_everything_with_types_from_JSDoc: diag(95043, DiagnosticCategory.Message, "Annotate_everything_with_types_from_JSDoc_95043", "Annotate everything with types from JSDoc"), + Add_to_all_uncalled_decorators: diag(95044, DiagnosticCategory.Message, "Add_to_all_uncalled_decorators_95044", "Add '()' to all uncalled decorators"), + Convert_all_constructor_functions_to_classes: diag(95045, DiagnosticCategory.Message, "Convert_all_constructor_functions_to_classes_95045", "Convert all constructor functions to classes"), + Generate_get_and_set_accessors: diag(95046, DiagnosticCategory.Message, "Generate_get_and_set_accessors_95046", "Generate 'get' and 'set' accessors"), + Convert_require_to_import: diag(95047, DiagnosticCategory.Message, "Convert_require_to_import_95047", "Convert 'require' to 'import'"), + Convert_all_require_to_import: diag(95048, DiagnosticCategory.Message, "Convert_all_require_to_import_95048", "Convert all 'require' to 'import'"), + Move_to_a_new_file: diag(95049, DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"), + Remove_unreachable_code: diag(95050, DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"), + Remove_all_unreachable_code: diag(95051, DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"), + Add_missing_typeof: diag(95052, DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"), + Remove_unused_label: diag(95053, DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"), + Remove_all_unused_labels: diag(95054, DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"), + Convert_0_to_mapped_object_type: diag(95055, DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"), + Convert_namespace_import_to_named_imports: diag(95056, DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"), + Convert_named_imports_to_namespace_import: diag(95057, DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"), + Add_or_remove_braces_in_an_arrow_function: diag(95058, DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), + Add_braces_to_arrow_function: diag(95059, DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), + Remove_braces_from_arrow_function: diag(95060, DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), + Convert_to_async_function: diag(95065, DiagnosticCategory.Message, "Convert_to_async_function_95065", "Convert to async function"), + Convert_all_to_async_functions: diag(95066, DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"), + Add_missing_call_parentheses: diag(95067, DiagnosticCategory.Message, "Add_missing_call_parentheses_95067", "Add missing call parentheses"), + Add_all_missing_call_parentheses: diag(95068, DiagnosticCategory.Message, "Add_all_missing_call_parentheses_95068", "Add all missing call parentheses"), + Add_unknown_conversion_for_non_overlapping_types: diag(95069, DiagnosticCategory.Message, "Add_unknown_conversion_for_non_overlapping_types_95069", "Add 'unknown' conversion for non-overlapping types"), + Add_unknown_to_all_conversions_of_non_overlapping_types: diag(95070, DiagnosticCategory.Message, "Add_unknown_to_all_conversions_of_non_overlapping_types_95070", "Add 'unknown' to all conversions of non-overlapping types"), + Add_missing_new_operator_to_call: diag(95071, DiagnosticCategory.Message, "Add_missing_new_operator_to_call_95071", "Add missing 'new' operator to call"), + Add_missing_new_operator_to_all_calls: diag(95072, DiagnosticCategory.Message, "Add_missing_new_operator_to_all_calls_95072", "Add missing 'new' operator to all calls"), + Add_names_to_all_parameters_without_names: diag(95073, DiagnosticCategory.Message, "Add_names_to_all_parameters_without_names_95073", "Add names to all parameters without names"), + Enable_the_experimentalDecorators_option_in_your_configuration_file: diag(95074, DiagnosticCategory.Message, "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074", "Enable the 'experimentalDecorators' option in your configuration file"), + Convert_parameters_to_destructured_object: diag(95075, DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"), + Extract_type: diag(95077, DiagnosticCategory.Message, "Extract_type_95077", "Extract type"), + Extract_to_type_alias: diag(95078, DiagnosticCategory.Message, "Extract_to_type_alias_95078", "Extract to type alias"), + Extract_to_typedef: diag(95079, DiagnosticCategory.Message, "Extract_to_typedef_95079", "Extract to typedef"), + Infer_this_type_of_0_from_usage: diag(95080, DiagnosticCategory.Message, "Infer_this_type_of_0_from_usage_95080", "Infer 'this' type of '{0}' from usage"), + Add_const_to_unresolved_variable: diag(95081, DiagnosticCategory.Message, "Add_const_to_unresolved_variable_95081", "Add 'const' to unresolved variable"), + Add_const_to_all_unresolved_variables: diag(95082, DiagnosticCategory.Message, "Add_const_to_all_unresolved_variables_95082", "Add 'const' to all unresolved variables"), + Add_await: diag(95083, DiagnosticCategory.Message, "Add_await_95083", "Add 'await'"), + Add_await_to_initializer_for_0: diag(95084, DiagnosticCategory.Message, "Add_await_to_initializer_for_0_95084", "Add 'await' to initializer for '{0}'"), + Fix_all_expressions_possibly_missing_await: diag(95085, DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), + Remove_unnecessary_await: diag(95086, DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), + Remove_all_unnecessary_uses_of_await: diag(95087, DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), + Convert_to_template_string: diag(95096, DiagnosticCategory.Message, "Convert_to_template_string_95096", "Convert to template string"), + Add_export_to_make_this_file_into_a_module: diag(95097, DiagnosticCategory.Message, "Add_export_to_make_this_file_into_a_module_95097", "Add 'export {}' to make this file into a module"), + Set_the_target_option_in_your_configuration_file_to_0: diag(95098, DiagnosticCategory.Message, "Set_the_target_option_in_your_configuration_file_to_0_95098", "Set the 'target' option in your configuration file to '{0}'"), + Set_the_module_option_in_your_configuration_file_to_0: diag(95099, DiagnosticCategory.Message, "Set_the_module_option_in_your_configuration_file_to_0_95099", "Set the 'module' option in your configuration file to '{0}'"), + Convert_invalid_character_to_its_html_entity_code: diag(95100, DiagnosticCategory.Message, "Convert_invalid_character_to_its_html_entity_code_95100", "Convert invalid character to its html entity code"), + Convert_all_invalid_characters_to_HTML_entity_code: diag(95101, DiagnosticCategory.Message, "Convert_all_invalid_characters_to_HTML_entity_code_95101", "Convert all invalid characters to HTML entity code"), + Convert_all_const_to_let: diag(95102, DiagnosticCategory.Message, "Convert_all_const_to_let_95102", "Convert all 'const' to 'let'"), + Convert_function_expression_0_to_arrow_function: diag(95105, DiagnosticCategory.Message, "Convert_function_expression_0_to_arrow_function_95105", "Convert function expression '{0}' to arrow function"), + Convert_function_declaration_0_to_arrow_function: diag(95106, DiagnosticCategory.Message, "Convert_function_declaration_0_to_arrow_function_95106", "Convert function declaration '{0}' to arrow function"), + Fix_all_implicit_this_errors: diag(95107, DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"), + Wrap_invalid_character_in_an_expression_container: diag(95108, DiagnosticCategory.Message, "Wrap_invalid_character_in_an_expression_container_95108", "Wrap invalid character in an expression container"), + Wrap_all_invalid_characters_in_an_expression_container: diag(95109, DiagnosticCategory.Message, "Wrap_all_invalid_characters_in_an_expression_container_95109", "Wrap all invalid characters in an expression container"), + Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file: diag(95110, DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig to read more about this file"), + Add_a_return_statement: diag(95111, DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"), + Remove_braces_from_arrow_function_body: diag(95112, DiagnosticCategory.Message, "Remove_braces_from_arrow_function_body_95112", "Remove braces from arrow function body"), + Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal: diag(95113, DiagnosticCategory.Message, "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113", "Wrap the following body with parentheses which should be an object literal"), + Add_all_missing_return_statement: diag(95114, DiagnosticCategory.Message, "Add_all_missing_return_statement_95114", "Add all missing return statement"), + Remove_braces_from_all_arrow_function_bodies_with_relevant_issues: diag(95115, DiagnosticCategory.Message, "Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115", "Remove braces from all arrow function bodies with relevant issues"), + Wrap_all_object_literal_with_parentheses: diag(95116, DiagnosticCategory.Message, "Wrap_all_object_literal_with_parentheses_95116", "Wrap all object literal with parentheses"), + Move_labeled_tuple_element_modifiers_to_labels: diag(95117, DiagnosticCategory.Message, "Move_labeled_tuple_element_modifiers_to_labels_95117", "Move labeled tuple element modifiers to labels"), + Convert_overload_list_to_single_signature: diag(95118, DiagnosticCategory.Message, "Convert_overload_list_to_single_signature_95118", "Convert overload list to single signature"), + Generate_get_and_set_accessors_for_all_overriding_properties: diag(95119, DiagnosticCategory.Message, "Generate_get_and_set_accessors_for_all_overriding_properties_95119", "Generate 'get' and 'set' accessors for all overriding properties"), + Wrap_in_JSX_fragment: diag(95120, DiagnosticCategory.Message, "Wrap_in_JSX_fragment_95120", "Wrap in JSX fragment"), + Wrap_all_unparented_JSX_in_JSX_fragment: diag(95121, DiagnosticCategory.Message, "Wrap_all_unparented_JSX_in_JSX_fragment_95121", "Wrap all unparented JSX in JSX fragment"), + Convert_arrow_function_or_function_expression: diag(95122, DiagnosticCategory.Message, "Convert_arrow_function_or_function_expression_95122", "Convert arrow function or function expression"), + Convert_to_anonymous_function: diag(95123, DiagnosticCategory.Message, "Convert_to_anonymous_function_95123", "Convert to anonymous function"), + Convert_to_named_function: diag(95124, DiagnosticCategory.Message, "Convert_to_named_function_95124", "Convert to named function"), + Convert_to_arrow_function: diag(95125, DiagnosticCategory.Message, "Convert_to_arrow_function_95125", "Convert to arrow function"), + Remove_parentheses: diag(95126, DiagnosticCategory.Message, "Remove_parentheses_95126", "Remove parentheses"), + Could_not_find_a_containing_arrow_function: diag(95127, DiagnosticCategory.Message, "Could_not_find_a_containing_arrow_function_95127", "Could not find a containing arrow function"), + Containing_function_is_not_an_arrow_function: diag(95128, DiagnosticCategory.Message, "Containing_function_is_not_an_arrow_function_95128", "Containing function is not an arrow function"), + Could_not_find_export_statement: diag(95129, DiagnosticCategory.Message, "Could_not_find_export_statement_95129", "Could not find export statement"), + This_file_already_has_a_default_export: diag(95130, DiagnosticCategory.Message, "This_file_already_has_a_default_export_95130", "This file already has a default export"), + Could_not_find_import_clause: diag(95131, DiagnosticCategory.Message, "Could_not_find_import_clause_95131", "Could not find import clause"), + Could_not_find_namespace_import_or_named_imports: diag(95132, DiagnosticCategory.Message, "Could_not_find_namespace_import_or_named_imports_95132", "Could not find namespace import or named imports"), + Selection_is_not_a_valid_type_node: diag(95133, DiagnosticCategory.Message, "Selection_is_not_a_valid_type_node_95133", "Selection is not a valid type node"), + No_type_could_be_extracted_from_this_type_node: diag(95134, DiagnosticCategory.Message, "No_type_could_be_extracted_from_this_type_node_95134", "No type could be extracted from this type node"), + Could_not_find_property_for_which_to_generate_accessor: diag(95135, DiagnosticCategory.Message, "Could_not_find_property_for_which_to_generate_accessor_95135", "Could not find property for which to generate accessor"), + Name_is_not_valid: diag(95136, DiagnosticCategory.Message, "Name_is_not_valid_95136", "Name is not valid"), + Can_only_convert_property_with_modifier: diag(95137, DiagnosticCategory.Message, "Can_only_convert_property_with_modifier_95137", "Can only convert property with modifier"), + Switch_each_misused_0_to_1: diag(95138, DiagnosticCategory.Message, "Switch_each_misused_0_to_1_95138", "Switch each misused '{0}' to '{1}'"), + Convert_to_optional_chain_expression: diag(95139, DiagnosticCategory.Message, "Convert_to_optional_chain_expression_95139", "Convert to optional chain expression"), + Could_not_find_convertible_access_expression: diag(95140, DiagnosticCategory.Message, "Could_not_find_convertible_access_expression_95140", "Could not find convertible access expression"), + Could_not_find_matching_access_expressions: diag(95141, DiagnosticCategory.Message, "Could_not_find_matching_access_expressions_95141", "Could not find matching access expressions"), + Can_only_convert_logical_AND_access_chains: diag(95142, DiagnosticCategory.Message, "Can_only_convert_logical_AND_access_chains_95142", "Can only convert logical AND access chains"), + Add_void_to_Promise_resolved_without_a_value: diag(95143, DiagnosticCategory.Message, "Add_void_to_Promise_resolved_without_a_value_95143", "Add 'void' to Promise resolved without a value"), + Add_void_to_all_Promises_resolved_without_a_value: diag(95144, DiagnosticCategory.Message, "Add_void_to_all_Promises_resolved_without_a_value_95144", "Add 'void' to all Promises resolved without a value"), + Use_element_access_for_0: diag(95145, DiagnosticCategory.Message, "Use_element_access_for_0_95145", "Use element access for '{0}'"), + Use_element_access_for_all_undeclared_properties: diag(95146, DiagnosticCategory.Message, "Use_element_access_for_all_undeclared_properties_95146", "Use element access for all undeclared properties."), + Delete_all_unused_imports: diag(95147, DiagnosticCategory.Message, "Delete_all_unused_imports_95147", "Delete all unused imports"), + Infer_function_return_type: diag(95148, DiagnosticCategory.Message, "Infer_function_return_type_95148", "Infer function return type"), + Return_type_must_be_inferred_from_a_function: diag(95149, DiagnosticCategory.Message, "Return_type_must_be_inferred_from_a_function_95149", "Return type must be inferred from a function"), + Could_not_determine_function_return_type: diag(95150, DiagnosticCategory.Message, "Could_not_determine_function_return_type_95150", "Could not determine function return type"), + Could_not_convert_to_arrow_function: diag(95151, DiagnosticCategory.Message, "Could_not_convert_to_arrow_function_95151", "Could not convert to arrow function"), + Could_not_convert_to_named_function: diag(95152, DiagnosticCategory.Message, "Could_not_convert_to_named_function_95152", "Could not convert to named function"), + Could_not_convert_to_anonymous_function: diag(95153, DiagnosticCategory.Message, "Could_not_convert_to_anonymous_function_95153", "Could not convert to anonymous function"), + Can_only_convert_string_concatenation: diag(95154, DiagnosticCategory.Message, "Can_only_convert_string_concatenation_95154", "Can only convert string concatenation"), + Selection_is_not_a_valid_statement_or_statements: diag(95155, DiagnosticCategory.Message, "Selection_is_not_a_valid_statement_or_statements_95155", "Selection is not a valid statement or statements"), + Add_missing_function_declaration_0: diag(95156, DiagnosticCategory.Message, "Add_missing_function_declaration_0_95156", "Add missing function declaration '{0}'"), + Add_all_missing_function_declarations: diag(95157, DiagnosticCategory.Message, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"), + Method_not_implemented: diag(95158, DiagnosticCategory.Message, "Method_not_implemented_95158", "Method not implemented."), + Function_not_implemented: diag(95159, DiagnosticCategory.Message, "Function_not_implemented_95159", "Function not implemented."), + Add_override_modifier: diag(95160, DiagnosticCategory.Message, "Add_override_modifier_95160", "Add 'override' modifier"), + Remove_override_modifier: diag(95161, DiagnosticCategory.Message, "Remove_override_modifier_95161", "Remove 'override' modifier"), + Add_all_missing_override_modifiers: diag(95162, DiagnosticCategory.Message, "Add_all_missing_override_modifiers_95162", "Add all missing 'override' modifiers"), + Remove_all_unnecessary_override_modifiers: diag(95163, DiagnosticCategory.Message, "Remove_all_unnecessary_override_modifiers_95163", "Remove all unnecessary 'override' modifiers"), + Can_only_convert_named_export: diag(95164, DiagnosticCategory.Message, "Can_only_convert_named_export_95164", "Can only convert named export"), + Add_missing_properties: diag(95165, DiagnosticCategory.Message, "Add_missing_properties_95165", "Add missing properties"), + Add_all_missing_properties: diag(95166, DiagnosticCategory.Message, "Add_all_missing_properties_95166", "Add all missing properties"), + Add_missing_attributes: diag(95167, DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"), + Add_all_missing_attributes: diag(95168, DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"), + Add_undefined_to_optional_property_type: diag(95169, DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"), + Convert_named_imports_to_default_import: diag(95170, DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"), + Delete_unused_param_tag_0: diag(95171, DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"), + Delete_all_unused_param_tags: diag(95172, DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"), + Rename_param_tag_name_0_to_1: diag(95173, DiagnosticCategory.Message, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"), + Use_0: diag(95174, DiagnosticCategory.Message, "Use_0_95174", "Use `{0}`."), + Use_Number_isNaN_in_all_conditions: diag(95175, DiagnosticCategory.Message, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."), + No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), + Classes_may_not_have_a_field_named_constructor: diag(18006, DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), + JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), + Private_identifiers_cannot_be_used_as_parameters: diag(18009, DiagnosticCategory.Error, "Private_identifiers_cannot_be_used_as_parameters_18009", "Private identifiers cannot be used as parameters."), + An_accessibility_modifier_cannot_be_used_with_a_private_identifier: diag(18010, DiagnosticCategory.Error, "An_accessibility_modifier_cannot_be_used_with_a_private_identifier_18010", "An accessibility modifier cannot be used with a private identifier."), + The_operand_of_a_delete_operator_cannot_be_a_private_identifier: diag(18011, DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011", "The operand of a 'delete' operator cannot be a private identifier."), + constructor_is_a_reserved_word: diag(18012, DiagnosticCategory.Error, "constructor_is_a_reserved_word_18012", "'#constructor' is a reserved word."), + Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier: diag(18013, DiagnosticCategory.Error, "Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier_18013", "Property '{0}' is not accessible outside class '{1}' because it has a private identifier."), + The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_private_identifier_with_the_same_spelling: diag(18014, DiagnosticCategory.Error, "The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_priv_18014", "The property '{0}' cannot be accessed on type '{1}' within this class because it is shadowed by another private identifier with the same spelling."), + Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2: diag(18015, DiagnosticCategory.Error, "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015", "Property '{0}' in type '{1}' refers to a different member that cannot be accessed from within type '{2}'."), + Private_identifiers_are_not_allowed_outside_class_bodies: diag(18016, DiagnosticCategory.Error, "Private_identifiers_are_not_allowed_outside_class_bodies_18016", "Private identifiers are not allowed outside class bodies."), + The_shadowing_declaration_of_0_is_defined_here: diag(18017, DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"), + The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"), + _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier."), + An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."), + can_only_be_used_at_the_start_of_a_file: diag(18026, DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."), + Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."), + Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher: diag(18028, DiagnosticCategory.Error, "Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher_18028", "Private identifiers are only available when targeting ECMAScript 2015 and higher."), + Private_identifiers_are_not_allowed_in_variable_declarations: diag(18029, DiagnosticCategory.Error, "Private_identifiers_are_not_allowed_in_variable_declarations_18029", "Private identifiers are not allowed in variable declarations."), + An_optional_chain_cannot_contain_private_identifiers: diag(18030, DiagnosticCategory.Error, "An_optional_chain_cannot_contain_private_identifiers_18030", "An optional chain cannot contain private identifiers."), + The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents: diag(18031, DiagnosticCategory.Error, "The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituent_18031", "The intersection '{0}' was reduced to 'never' because property '{1}' has conflicting types in some constituents."), + The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some: diag(18032, DiagnosticCategory.Error, "The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_pr_18032", "The intersection '{0}' was reduced to 'never' because property '{1}' exists in multiple constituents and is private in some."), + Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values: diag(18033, DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values_18033", "Type '{0}' is not assignable to type '{1}' as required for computed enum member values."), + Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."), + Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."), + Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator: diag(18036, DiagnosticCategory.Error, "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036", "Class decorators can't be used with static private identifier. Consider removing the experimental decorator."), + Await_expression_cannot_be_used_inside_a_class_static_block: diag(18037, DiagnosticCategory.Error, "Await_expression_cannot_be_used_inside_a_class_static_block_18037", "Await expression cannot be used inside a class static block."), + For_await_loops_cannot_be_used_inside_a_class_static_block: diag(18038, DiagnosticCategory.Error, "For_await_loops_cannot_be_used_inside_a_class_static_block_18038", "'For await' loops cannot be used inside a class static block."), + Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block: diag(18039, DiagnosticCategory.Error, "Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block_18039", "Invalid use of '{0}'. It cannot be used inside a class static block."), + A_return_statement_cannot_be_used_inside_a_class_static_block: diag(18041, DiagnosticCategory.Error, "A_return_statement_cannot_be_used_inside_a_class_static_block_18041", "A 'return' statement cannot be used inside a class static block."), + _0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation: diag(18042, DiagnosticCategory.Error, "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042", "'{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation."), + Types_cannot_appear_in_export_declarations_in_JavaScript_files: diag(18043, DiagnosticCategory.Error, "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043", "Types cannot appear in export declarations in JavaScript files."), + _0_is_automatically_exported_here: diag(18044, DiagnosticCategory.Message, "_0_is_automatically_exported_here_18044", "'{0}' is automatically exported here."), + Properties_with_the_accessor_modifier_are_only_available_when_targeting_ECMAScript_2015_and_higher: diag(18045, DiagnosticCategory.Error, "Properties_with_the_accessor_modifier_are_only_available_when_targeting_ECMAScript_2015_and_higher_18045", "Properties with the 'accessor' modifier are only available when targeting ECMAScript 2015 and higher."), + _0_is_of_type_unknown: diag(18046, DiagnosticCategory.Error, "_0_is_of_type_unknown_18046", "'{0}' is of type 'unknown'."), + _0_is_possibly_null: diag(18047, DiagnosticCategory.Error, "_0_is_possibly_null_18047", "'{0}' is possibly 'null'."), + _0_is_possibly_undefined: diag(18048, DiagnosticCategory.Error, "_0_is_possibly_undefined_18048", "'{0}' is possibly 'undefined'."), + _0_is_possibly_null_or_undefined: diag(18049, DiagnosticCategory.Error, "_0_is_possibly_null_or_undefined_18049", "'{0}' is possibly 'null' or 'undefined'."), + The_value_0_cannot_be_used_here: diag(18050, DiagnosticCategory.Error, "The_value_0_cannot_be_used_here_18050", "The value '{0}' cannot be used here."), +}; \ No newline at end of file diff --git a/external-declarations/src/compiler/emit-binder.ts b/external-declarations/src/compiler/emit-binder.ts new file mode 100644 index 0000000000000..f65622b55cc30 --- /dev/null +++ b/external-declarations/src/compiler/emit-binder.ts @@ -0,0 +1,696 @@ +import { Symbol, Node, VariableDeclaration, ParameterDeclaration, ModifierFlags, isLiteralExpression, ClassElement, isIdentifier, BindingPattern, SyntaxKind, findAncestor, SourceFile, isVariableStatement, SymbolFlags, isImportDeclaration, __String, isFunctionDeclaration, isClassDeclaration, isTypeAliasDeclaration, isExportDeclaration, isExportAssignment, isModuleDeclaration, NodeArray, isConstructSignatureDeclaration, isConstructorDeclaration, isImportEqualsDeclaration, isEnumDeclaration, isInterfaceDeclaration, isNamedExports, isModuleBlock, ModuleDeclaration, ArrayBindingElement, isExternalModuleReference, forEachChild, isMetaProperty, isComputedPropertyName, isPropertyAccessExpression, isPrivateIdentifier, Extension, isConditionalTypeNode, TypeElement, CompilerOptions, ModuleKind, ModuleDetectionKind, isMappedTypeNode, TypeParameterDeclaration, isInferTypeNode, isBlock, InterfaceDeclaration, ClassDeclaration, FunctionDeclaration, JsxEmit, isJsxFragment, isJsxOpeningLikeElement, ModuleResolutionKind, ResolutionMode, isEnumMember, getNameOfDeclaration, ExportDeclaration, Identifier, isSourceFile, ExportSpecifier, EnumDeclaration, isVariableDeclaration } from "typescript"; +import { Debug } from "./debug"; +import { forEach } from "./lang-utils"; +import { _Symbol } from "./types"; +import { isBindingPattern, getNodeId, hasSyntacticModifier, getEmitModuleKind, getEmitModuleResolutionKind, isEnumConst, nodeHasName } from "./utils"; + + +export interface NodeLinks { + isVisible?: boolean; + symbol?: BasicSymbol; + localSymbol?: BasicSymbol; + locals?: SymbolTable; +} + +type SymbolTable = Map<__String, BasicSymbol>; +export interface BasicSymbol { + name?: __String + exportSymbol?: BasicSymbol; + declarations: Node[]; + signatureDeclarations?: Node[]; + flags: SymbolFlags; + isVisible?: boolean; + members?: SymbolTable; + exports?: SymbolTable; +} + +function assertNever(o: never): never { + throw new Error("Should never happen") +} + +type _Node = Node; +declare module 'typescript' { + interface SourceFile { + externalModuleIndicator?: _Node | true; + } +} +export function getEmitModuleDetectionKind(options: CompilerOptions) { + return options.moduleDetection || + (getEmitModuleKind(options) === ModuleKind.Node16 || getEmitModuleKind(options) === ModuleKind.NodeNext ? ModuleDetectionKind.Force : ModuleDetectionKind.Auto); +} + +type SymbolRegistrationFlags = readonly [flags: SymbolFlags, forbiddenFlags: SymbolFlags]; +const syntaxKindToSymbolMap = { + [SyntaxKind.TypeParameter]: [SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes], + [SyntaxKind.Parameter]: [SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes], + [SyntaxKind.VariableDeclaration]: [SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes], + [SyntaxKind.BindingElement]: [SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes], + [SyntaxKind.PropertyDeclaration]: [SymbolFlags.Property, SymbolFlags.PropertyExcludes], + [SyntaxKind.PropertySignature]: [SymbolFlags.Property, SymbolFlags.PropertyExcludes], + [SyntaxKind.PropertyAssignment]: [SymbolFlags.Property, SymbolFlags.PropertyExcludes], + [SyntaxKind.ShorthandPropertyAssignment]: [SymbolFlags.Property, SymbolFlags.PropertyExcludes], + [SyntaxKind.EnumMember]: [SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes], + [SyntaxKind.CallSignature]: [SymbolFlags.Signature, SymbolFlags.None], + [SyntaxKind.ConstructSignature]: [SymbolFlags.Signature, SymbolFlags.None], + [SyntaxKind.IndexSignature]: [SymbolFlags.Signature, SymbolFlags.None], + [SyntaxKind.MethodDeclaration]: [SymbolFlags.Method, SymbolFlags.MethodExcludes], + [SyntaxKind.MethodSignature]: [SymbolFlags.Method, SymbolFlags.MethodExcludes], + [SyntaxKind.FunctionDeclaration]: [SymbolFlags.Function, SymbolFlags.FunctionExcludes], + [SyntaxKind.Constructor]: [SymbolFlags.Constructor, SymbolFlags.None], + [SyntaxKind.GetAccessor]: [SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes], + [SyntaxKind.SetAccessor]: [SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes], + [SyntaxKind.ClassExpression]: [SymbolFlags.Class, SymbolFlags.ClassExcludes], + [SyntaxKind.ClassDeclaration]: [SymbolFlags.Class, SymbolFlags.ClassExcludes], + [SyntaxKind.InterfaceDeclaration]: [SymbolFlags.Interface, SymbolFlags.InterfaceExcludes], + [SyntaxKind.TypeAliasDeclaration]: [SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes], + [SyntaxKind.EnumDeclaration]: { + const: [SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes], + regular: [SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes], + }, + [SyntaxKind.ModuleDeclaration]: { + value: [SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes], + namespace: [SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes], + }, + [SyntaxKind.ImportEqualsDeclaration]: [SymbolFlags.Alias, SymbolFlags.AliasExcludes], + [SyntaxKind.NamespaceImport]: [SymbolFlags.Alias, SymbolFlags.AliasExcludes], + [SyntaxKind.ImportSpecifier]: [SymbolFlags.Alias, SymbolFlags.AliasExcludes], + [SyntaxKind.ExportSpecifier]: [SymbolFlags.Alias | SymbolFlags.ExportValue, SymbolFlags.AliasExcludes], + [SyntaxKind.NamespaceExportDeclaration]: [SymbolFlags.Alias, SymbolFlags.AliasExcludes], + [SyntaxKind.ImportClause]: [SymbolFlags.Alias, SymbolFlags.AliasExcludes], +} as const; //satisfies Partial>>; + +export function bindSourceFile(file: SourceFile, options: CompilerOptions, packageModuleType: ResolutionMode) { + const nodeLinks: NodeLinks[] = [] + function tryGetNodeLinks(node: Node): NodeLinks | undefined { + const id = (node as any).id; + if(!id) return undefined; + return nodeLinks[id]; + } + function getNodeLinks(node: Node): NodeLinks { + const nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); + } + + const [isFileAModule, isNodeAModuleIndicator] = getSetExternalModuleIndicator(options); + file.externalModuleIndicator = + isFileAModule(file) || isExternalModuleWorker(file, isNodeAModuleIndicator); + file.impliedNodeFormat = getImpliedNodeFormat(file.fileName, options, packageModuleType) + + bind(); + + return { + tryGetNodeLinks, + getNodeLinks, + resolveName, + } + + + function resolveName(enclosingDeclaration: Node, escapedText: __String, meaning: SymbolFlags) { + function getSymbolFromScope(table: SymbolTable | undefined) { + let symbol = table?.get(escapedText); + if(symbol && ((symbol.flags & meaning) || (symbol.flags & SymbolFlags.Alias))) { + return symbol + } + } + + let currentScope = enclosingDeclaration; + while(currentScope) { + const links = tryGetNodeLinks(currentScope); + let symbol = getSymbolFromScope(links?.locals); + if(!symbol && (isModuleDeclaration(currentScope) || isSourceFile(currentScope))) { + symbol = getSymbolFromScope(links?.symbol?.exports) + } + if(symbol) return symbol; + currentScope = currentScope.parent; + } + return undefined; + } + + function getSymbolFlagsForNode(node: Node & { kind: keyof typeof syntaxKindToSymbolMap }) { + if(node.kind === SyntaxKind.EnumDeclaration) { + return isEnumConst(node as EnumDeclaration) ? + syntaxKindToSymbolMap[node.kind].const: + syntaxKindToSymbolMap[node.kind].regular; + } + if(node.kind === SyntaxKind.ModuleDeclaration) { + return getModuleInstanceState(node as ModuleDeclaration) === ModuleInstanceState.Instantiated ? + syntaxKindToSymbolMap[node.kind].value: + syntaxKindToSymbolMap[node.kind].namespace; + } + return syntaxKindToSymbolMap[node.kind]; + } + function getElementFlagsOrThrow(node: Node) { + const result = getSymbolFlagsForNode(node as Node & { kind: keyof typeof syntaxKindToSymbolMap }); + if(!result) { + throw new Error("Unknown binding element type"); + } + return result; + } + + function bind() { + let currentScope: Node = undefined!; + let currentSymbol: BasicSymbol = undefined!; + let currentLocalSymbolTable: SymbolTable = undefined!; + let currentExportsSymbolTable: SymbolTable | null = null; + let postBindingAction: Array<() => void> = []; + + const fileLinks = getNodeLinks(file).symbol = newSymbol(); + fileLinks.exports = new Map(); + withScope(file, fileLinks.exports, ()=> bindEachFunctionsFirst(file.statements)); + postBindingAction.forEach(fn => fn()); + + function newSymbol(): BasicSymbol { + return { + declarations: [], + flags: 0, + } + } + function getSymbol(table: SymbolTable, name: __String) { + let symbol = table.get(name); + if(!symbol) { + symbol = newSymbol(); + symbol.name = name; + table.set(name, symbol) + } + return symbol; + } + function addLocalAndExportDeclaration(name: __String | undefined, node: Node, [flags, forbiddenFlags]: SymbolRegistrationFlags, isExport: boolean) { + if(isExport) { + const exportKind = flags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0; + const localSymbol = addLocalOnlyDeclaration(name, node, [exportKind, forbiddenFlags]); + const exportSymbol = addExportOnlyDeclaration(name, node, [flags, forbiddenFlags]); + localSymbol.exportSymbol = exportSymbol + return exportSymbol; + }else { + return addLocalOnlyDeclaration(name, node, [flags, forbiddenFlags]); + } + } + function addExportOnlyDeclaration(name: __String | undefined, node: Node, flagsAndForbiddenFlags: SymbolRegistrationFlags) { + if(!currentExportsSymbolTable) { + throw new Error("Exporting symbol from a context that does not support it"); + } + return addDeclaration(currentExportsSymbolTable, name, node, flagsAndForbiddenFlags); + } + function addLocalOnlyDeclaration(name: __String | undefined, node: Node, flagsAndForbiddenFlags: SymbolRegistrationFlags) { + return addDeclaration(currentLocalSymbolTable, name, node, flagsAndForbiddenFlags); + } + + function addDeclaration(table: SymbolTable, name: __String | undefined, node: Node, [flags, forbiddenFlags]: SymbolRegistrationFlags) { + let symbol = name != null ? getSymbol(table, name) : newSymbol(); + // Symbols don't merge, create new one + if(forbiddenFlags & symbol.flags) { + symbol = newSymbol(); + } + symbol.declarations.push(node); + symbol.flags |= flags; + getNodeLinks(node).symbol = symbol; + node.symbol = symbol as unknown as Symbol; + return symbol; + } + function withScope(scope: Node, exports: SymbolTable | null, fn: () => void) { + const old = [currentScope, currentLocalSymbolTable, currentExportsSymbolTable] as const + currentScope = scope; + const links = getNodeLinks(scope); + currentLocalSymbolTable = (links.locals ??= new Map()); + currentExportsSymbolTable = exports; + fn(); + [currentScope, currentLocalSymbolTable, currentExportsSymbolTable] = old; + } + function withMembers(symbol: BasicSymbol, fn:()=> void, table: "members" | "exports" = "members") { + const old = [currentLocalSymbolTable, currentSymbol] as const + currentSymbol = symbol; + currentLocalSymbolTable = (symbol[table] ??= new Map()); + fn(); + [currentLocalSymbolTable, currentSymbol] = old; + } + + /** + * Gets the symbolic name for a member from its type. + */ + function getMemberName(element: TypeElement | ClassElement): __String | undefined{ + if (isConstructorDeclaration(element) || isConstructSignatureDeclaration(element)) { + return "@constructor" as __String; + } + const name = element.name; + if(!name) return undefined; + if(isIdentifier(name)) { + return name.escapedText; + } + else if(isLiteralExpression(name)) { + return `${name.text}` as __String; + } + else if(isComputedPropertyName(name)) { + let expr = name.expression; + + if(isLiteralExpression(expr)) { + return `${expr.text}` as __String; + } + + let fullName = "" + while(isPropertyAccessExpression(expr)) { + fullName = "." + expr.name.escapedText + name + expr = expr.expression; + } + if(!isIdentifier(expr)) { + return undefined; + } + return `[${expr.escapedText}${fullName}]` as __String; + } else if(isPrivateIdentifier(name)) { + return name.escapedText; + } else { + assertNever(name) + } + } + + function getStatementName(s: InterfaceDeclaration | ClassDeclaration | FunctionDeclaration) { + if(hasSyntacticModifier(s, ModifierFlags.Export) && hasSyntacticModifier(s, ModifierFlags.Default)) { + return "@default" as __String; + } + if(s.name) { + return s.name.escapedText; + } + } + // We need to bind locals for types (conditional and mapped typed define parameters in their definitions) + function bindTypeExpressions(node?: Node) { + function bindChildren(node: Node) { + forEachChild(node, bindWorker, arr => arr.forEach(bindWorker)); + } + function bindWorker(node?: Node) { + if(!node) return; + if(isMappedTypeNode(node)) { + const mappedType = node; + withScope(node, null, () => { + bindTypeParameters([mappedType.typeParameter]); + bindWorker(mappedType.nameType); + bindWorker(mappedType.type); + }); + } + else if(isConditionalTypeNode(node)) { + withScope(node.checkType, null, () => { + bindWorker(node.extendsType); + }) + getNodeLinks(node.trueType).locals = getNodeLinks(node.checkType).locals + } if(isInferTypeNode(node)) { + const conditionalTypeOwner = findAncestor(node, isConditionalTypeNode); + // Probably an error, infer not in a conditional type context + // Try to bind the rest of it + if(conditionalTypeOwner) { + withScope(conditionalTypeOwner, null, () => { + bindTypeParameters([node.typeParameter]); + }); + } + bindChildren(node); + } + else if(isBlock(node)) { + // Do not go into bodies + return; + } + else { + bindChildren(node); + } + } + bindWorker(node) + } + function bindTypeParameters(typeParameters: TypeParameterDeclaration[] | NodeArray | undefined) { + typeParameters?.forEach(t => addLocalOnlyDeclaration(t.name.escapedText, t, getSymbolFlagsForNode(t))); + } + function bindVariable(d: VariableDeclaration | ParameterDeclaration) { + bindTypeExpressions(d.type); + const isExported = isVariableDeclaration(d) && hasSyntacticModifier(d.parent.parent, ModifierFlags.Export); + if(isIdentifier(d.name)) { + addLocalAndExportDeclaration(d.name.escapedText, d, getSymbolFlagsForNode(d), isExported); + } + else if(isBindingPattern(d.name)) { + function bindBindingPattern(pattern: BindingPattern) { + // type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; + (pattern.elements as NodeArray).forEach(b => { + if(b.kind === SyntaxKind.OmittedExpression) return; + if(!b.name) return; + + if(isIdentifier(b.name)) { + addLocalAndExportDeclaration(b.name.escapedText, b, getSymbolFlagsForNode(b), isExported); + } else { + bindBindingPattern(b.name); + } + }) + } + bindBindingPattern(d.name); + } else { + assertNever(d.name) + } + } + function bindEachFunctionsFirst(nodes: NodeArray | undefined): void { + if(!nodes) return; + bindContainer(nodes.filter(n => n.kind === SyntaxKind.FunctionDeclaration)); + bindContainer(nodes.filter(n => n.kind !== SyntaxKind.FunctionDeclaration)); + } + + function bindContainer(statements: NodeArray | Node[]) { + statements.forEach(statement => { + const isExported = hasSyntacticModifier(statement, ModifierFlags.Export); + if(isImportEqualsDeclaration(statement)) { + addLocalOnlyDeclaration(statement.name.escapedText, statement, getSymbolFlagsForNode(statement)); + } + if(isImportDeclaration(statement)) { + if(!statement.importClause) { + return; + } + if(statement.importClause.name) { + addLocalOnlyDeclaration(statement.importClause.name.escapedText, statement.importClause, getSymbolFlagsForNode(statement.importClause)); + } + if(statement.importClause.namedBindings) { + const namedBindings = statement.importClause.namedBindings; + if(namedBindings.kind === SyntaxKind.NamedImports) { + namedBindings.elements.forEach(v => { + addLocalOnlyDeclaration(v.name.escapedText, v, getSymbolFlagsForNode(v)); + }) + } + else if(namedBindings.kind === SyntaxKind.NamespaceImport) { + addLocalOnlyDeclaration(namedBindings.name.escapedText, namedBindings, getSymbolFlagsForNode(namedBindings)); + } else { + debugger; + throw new Error("Not supported"); + } + } + } + if(isVariableStatement(statement)) { + statement.declarationList.declarations.forEach(bindVariable); + } + if(isFunctionDeclaration(statement)) { + bindTypeParameters(statement.typeParameters); + bindTypeExpressions(statement.type); + withScope(statement, null, () => { + bindTypeExpressions(statement); + statement.parameters.forEach(bindVariable); + }); + + addLocalAndExportDeclaration(getStatementName(statement), statement, getSymbolFlagsForNode(statement), isExported); + } + if(isTypeAliasDeclaration(statement)) { + addLocalAndExportDeclaration(statement.name.escapedText, statement, getSymbolFlagsForNode(statement), isExported); + withScope(statement, null, () => { + bindTypeParameters(statement.typeParameters); + }); + bindTypeExpressions(statement.type); + } + // Default export declarations set isVisible on true on associated symbols in the type checker. + if(isExportAssignment(statement)) { + if(statement.expression && isIdentifier(statement.expression)) { + const name = statement.expression.escapedText; + postBindingAction.push(() => { + const resolvedSymbol = resolveName(statement.expression, name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); + if(resolvedSymbol) { + resolvedSymbol.isVisible = true; + resolvedSymbol.declarations.forEach(d => getNodeLinks(d).isVisible = true); + } + }); + } + } + if(isExportDeclaration(statement)) { + if(statement.exportClause && isNamedExports(statement.exportClause)) { + const elements = statement.exportClause.elements; + if (statement.moduleSpecifier) { + // TODO is currentExportsSymbolTable ok here? + withScope(statement, null, () => { + elements.forEach(e => { + const [flags, forbiddenFlags] = getSymbolFlagsForNode(e) + addLocalOnlyDeclaration((e.propertyName ?? e.name).escapedText, e, [flags | SymbolFlags.ExportValue , forbiddenFlags]); + }); + }) + } + elements.forEach(e => { + postBindingAction.push(() => { + const resolvedSymbol = resolveName(e,(e.propertyName ?? e.name).escapedText, ~0); + if(resolvedSymbol) { + resolvedSymbol.isVisible = true; + resolvedSymbol.declarations.forEach(d => getNodeLinks(d).isVisible = true); + } + }); + }) + } + } + // if(isEnumMember(statement)) { + // addDeclaration(getNameOfDeclaration(statement.name), statement, getElementFlags(statement.kind)); + // } + if(isEnumDeclaration(statement)) { + addLocalAndExportDeclaration(statement.name.escapedText, statement, getSymbolFlagsForNode(statement), isExported); + // withScope(statement, () => bindContainer(statement.members)) + } + if(isModuleDeclaration(statement)) { + function bindModuleDeclaration(moduleDeclaration: ModuleDeclaration) { + const name = isIdentifier(moduleDeclaration.name) ? moduleDeclaration.name.escapedText: undefined; + const moduleSymbol = addLocalAndExportDeclaration(name, moduleDeclaration, getSymbolFlagsForNode(moduleDeclaration), isExported); + moduleSymbol.exports ??= new Map(); + withScope(moduleDeclaration, moduleSymbol.exports, () => { + if(moduleDeclaration.body) { + if(isModuleBlock(moduleDeclaration.body)) { + const moduleBlock = moduleDeclaration.body + bindEachFunctionsFirst(moduleBlock.statements) + } + else if(isModuleDeclaration(moduleDeclaration.body)) { + const subModule = moduleDeclaration.body; + bindModuleDeclaration(subModule); + } else { + throw new Error("Unsupported body type"); + } + } + }); + } + bindModuleDeclaration(statement); + } + if(isInterfaceDeclaration(statement)) { + const interfaceDeclaration = statement; + const interfaceSymbol = addLocalAndExportDeclaration(interfaceDeclaration.name.escapedText, interfaceDeclaration, getSymbolFlagsForNode(interfaceDeclaration), isExported); + withScope(interfaceDeclaration, null, () =>{ + bindTypeParameters(interfaceDeclaration.typeParameters); + }); + withMembers(interfaceSymbol, () => { + interfaceDeclaration.members.forEach(m => { + addLocalOnlyDeclaration(getMemberName(m), m, getElementFlagsOrThrow(m)); + bindTypeExpressions(m) + }) + }); + } + + if(isClassDeclaration(statement)) { + const classDeclaration = statement; + const classSymbol = addLocalAndExportDeclaration(classDeclaration.name?.escapedText, classDeclaration, getSymbolFlagsForNode(classDeclaration), isExported); + withScope(classDeclaration, null, () =>{ + bindTypeParameters(classDeclaration.typeParameters); + }); + withMembers(classSymbol, () => { + classDeclaration.members.forEach(m => { + if(hasSyntacticModifier(m, ModifierFlags.Static)) return; + if(m.kind === SyntaxKind.SemicolonClassElement || m.kind === SyntaxKind.ClassStaticBlockDeclaration) return; + + addLocalOnlyDeclaration(getMemberName(m), m, getElementFlagsOrThrow(m)); + bindTypeExpressions(m) + }) + }); + withMembers(classSymbol, () => { + classDeclaration.members.forEach(m => { + if(!hasSyntacticModifier(m, ModifierFlags.Static)) return; + if(m.kind === SyntaxKind.SemicolonClassElement + || m.kind === SyntaxKind.ClassStaticBlockDeclaration) return; + + addLocalOnlyDeclaration(getMemberName(m), m, getElementFlagsOrThrow(m)); + bindTypeExpressions(m) + }) + }, "exports"); + } + }) + } + } +} + +function isExternalModuleWorker(file: SourceFile, isModuleIndicatorNode: (node: Node) => boolean): Node | undefined { + return ( + forEach(file.statements, isAnExternalModuleIndicatorNode) || walkTreeForModuleIndicator(file, isModuleIndicatorNode) + // TODO: isolatedDeclarations: find a away to detect commonJS modules + ) +} + +function isAnExternalModuleIndicatorNode(node: Node) { + return hasSyntacticModifier(node, ModifierFlags.Export) + || isImportEqualsDeclaration(node) && isExternalModuleReference(node.moduleReference) + || isImportDeclaration(node) + || isExportAssignment(node) + || isExportDeclaration(node) ? node : undefined; +} + +function walkTreeForModuleIndicator(node: Node, isModuleIndicatorNode: (node: Node) => boolean) { + function walkTreeForModuleIndicatorWorker(node: Node): Node | undefined { + return isModuleIndicatorNode(node) ? node : forEachChild(node, walkTreeForModuleIndicatorWorker); + } + return walkTreeForModuleIndicatorWorker(node); +} +function isImportMeta(node: Node): boolean { + return isMetaProperty(node) && node.keywordToken === SyntaxKind.ImportKeyword && node.name.escapedText === "meta"; +} + + + +/** @internal */ +export function getSetExternalModuleIndicator(options: CompilerOptions): [(node: SourceFile) => true | undefined, (node: Node) => boolean] { + + function isFileForcedToBeModuleByFormat(file: SourceFile): true | undefined { + // Excludes declaration files - they still require an explicit `export {}` or the like + // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files + // that aren't esm-mode (meaning not in a `type: module` scope). + return ([Extension.Cjs, Extension.Cts, Extension.Mjs, Extension.Mts].some(e => file.fileName.endsWith(e)) ? true : undefined); + } + + // TODO: Should this callback be cached? + switch (getEmitModuleDetectionKind(options)) { + case ModuleDetectionKind.Force: + // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule + return [(file) => !file.isDeclarationFile || undefined, () => true]; + + case ModuleDetectionKind.Legacy: + // Files are modules if they have imports, exports, or import.meta + return [isFileForcedToBeModuleByFormat, isImportMeta]; + + case ModuleDetectionKind.Auto: + + return [ + isFileForcedToBeModuleByFormat, + options.jsx === JsxEmit.ReactJSX || options.jsx === JsxEmit.ReactJSXDev? + n => isImportMeta(n) || isJsxOpeningLikeElement(n) || isJsxFragment(n): + isImportMeta + ] + } +} + +function getImpliedNodeFormat(fileName: string, options: CompilerOptions, packageJsonFormat: ResolutionMode) { + switch (getEmitModuleResolutionKind(options)) { + case ModuleResolutionKind.Node16: + case ModuleResolutionKind.NodeNext: + return [Extension.Dmts, Extension.Mts, Extension.Mjs].some(e => fileName.endsWith(e)) ? ModuleKind.ESNext : + [Extension.Dcts, Extension.Cts, Extension.Cjs].some(e => fileName.endsWith(e)) ? ModuleKind.CommonJS : + [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx].some(e => fileName.endsWith(e)) ? packageJsonFormat : + undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline + default: + return undefined; + } +} + +export const enum ModuleInstanceState { + NonInstantiated = 0, + Instantiated = 1, + ConstEnumOnly = 2 +} + +export function getModuleInstanceState(node: ModuleDeclaration, visited?: Map): ModuleInstanceState { + return node.body ? getModuleInstanceStateCached(node.body, visited) : ModuleInstanceState.Instantiated; +} + +function getModuleInstanceStateCached(node: Node, visited = new Map()) { + const nodeId = getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || ModuleInstanceState.NonInstantiated; + } + visited.set(nodeId, undefined); + const result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; +} + +function getModuleInstanceStateWorker(node: Node, visited: Map): ModuleInstanceState { + // A module is uninstantiated if it contains only + switch (node.kind) { + // 1. interface declarations, type alias declarations + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.TypeAliasDeclaration: + return ModuleInstanceState.NonInstantiated; + // 2. const enum declarations + case SyntaxKind.EnumDeclaration: + if (isEnumConst(node as EnumDeclaration)) { + return ModuleInstanceState.ConstEnumOnly; + } + break; + // 3. non-exported import declarations + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + if (!(hasSyntacticModifier(node, ModifierFlags.Export))) { + return ModuleInstanceState.NonInstantiated; + } + break; + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case SyntaxKind.ExportDeclaration: + const exportDeclaration = node as ExportDeclaration; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === SyntaxKind.NamedExports) { + let state = ModuleInstanceState.NonInstantiated; + for (const specifier of exportDeclaration.exportClause.elements) { + const specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === ModuleInstanceState.Instantiated) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case SyntaxKind.ModuleBlock: { + let state = ModuleInstanceState.NonInstantiated; + forEachChild(node, n => { + const childState = getModuleInstanceStateCached(n, visited); + switch (childState) { + case ModuleInstanceState.NonInstantiated: + // child is non-instantiated - continue searching + return; + case ModuleInstanceState.ConstEnumOnly: + // child is const enum only - record state and continue searching + state = ModuleInstanceState.ConstEnumOnly; + return; + case ModuleInstanceState.Instantiated: + // child is instantiated - record state and stop + state = ModuleInstanceState.Instantiated; + return true; + default: + Debug.assertNever(childState); + } + }); + return state; + } + case SyntaxKind.ModuleDeclaration: + return getModuleInstanceState(node as ModuleDeclaration, visited); + case SyntaxKind.Identifier: + // Only jsdoc typedef definition can exist in jsdoc namespace, and it should + // be considered the same as type alias + if ((node as Identifier).isInJSDocNamespace) { + return ModuleInstanceState.NonInstantiated; + } + } + return ModuleInstanceState.Instantiated; +} + +function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: Map) { + const name = specifier.propertyName || specifier.name; + let p: Node | undefined = specifier.parent; + while (p) { + if (isBlock(p) || isModuleBlock(p) || isSourceFile(p)) { + const statements = p.statements; + let found: ModuleInstanceState | undefined; + for (const statement of statements) { + if (nodeHasName(statement, name)) { + const state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === ModuleInstanceState.Instantiated) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return ModuleInstanceState.Instantiated; // Couldn't locate, assume could refer to a value +} + diff --git a/external-declarations/src/compiler/emit-host.ts b/external-declarations/src/compiler/emit-host.ts new file mode 100644 index 0000000000000..a94c259cfe838 --- /dev/null +++ b/external-declarations/src/compiler/emit-host.ts @@ -0,0 +1,69 @@ + +import * as ts from 'typescript' +import { changeExtension } from '../test-runner/tsc-infrastructure/vpath'; +import { getDeclarationExtension, getDirectoryPath, getRelativePathFromDirectory, hasExtension, isDeclarationFile, isJavaScriptFile, resolvePath } from './path-utils'; +import { EmitHost } from './types'; +import { getNodeId } from './utils'; + + +export function createEmitHost(allProjectFiles: string[], tsLibFiles: string[], options: ts.CompilerOptions) { + const getCompilerOptions = () => options; + const getCurrentDirectory = () => "."; + const getCommonSourceDirectory = () => "."; + const getCanonicalFileName = (f: string) => `./${f}`; + const projectFileMap = new Map(allProjectFiles + .map((f) => ({ kind: ts.SyntaxKind.SourceFile, fileName: f } as ts.SourceFile)) + .map(f => [f.fileName, getNodeId(f)]) + ) + const tsLibFileSet = new Set(tsLibFiles); + + return { + getSourceFiles() { + throw new Error("Not needed"); + // return [sourceFile] + }, + getCompilerOptions, + getCurrentDirectory, + getCommonSourceDirectory, + getCanonicalFileName, + getLibFileFromReference(ref) { + if(options.noLib) { + return undefined; + } + if(!tsLibFileSet.has(ref.fileName)) { + return; + } + return { + fileName: ref.fileName, + } + }, + getSourceFileFromReference(referencingFile, ref) { + if(ref.fileName.startsWith("node_modules/") || ref.fileName.indexOf("/node_modules/") !== -1) { + return undefined; + } + if(isJavaScriptFile(ref.fileName) && !options.allowJs) { + return; + } + let resolvedFile: string | undefined = resolvePath(getDirectoryPath(referencingFile.fileName), ref.fileName); + let resolvedFileId = projectFileMap.get(resolvedFile) + if(!hasExtension(resolvedFile) && resolvedFileId == undefined) { + [resolvedFile, resolvedFileId] = Object.values(ts.Extension) + .map(e => resolvedFile + e) + .map(f => [f, projectFileMap.get(f)] as const) + .find(([_, id]) => id != undefined) ?? []; + + if(!resolvedFile) return undefined; + } + if(!projectFileMap.has(resolvedFile)) { + return undefined; + } + const resolvedDeclarationFile = + isDeclarationFile(resolvedFile) ? resolvedFile : + changeExtension(resolvedFile, getDeclarationExtension(resolvedFile)) + return { + fileName: getRelativePathFromDirectory(getDirectoryPath(referencingFile.fileName), resolvedDeclarationFile, false), + id: resolvedFileId, + }; + }, + } as Partial as EmitHost +} \ No newline at end of file diff --git a/external-declarations/src/compiler/emit-resolver.ts b/external-declarations/src/compiler/emit-resolver.ts new file mode 100644 index 0000000000000..636cf7d62fc4d --- /dev/null +++ b/external-declarations/src/compiler/emit-resolver.ts @@ -0,0 +1,405 @@ +import { Node, VariableDeclaration, PropertyDeclaration, PropertySignature, ParameterDeclaration, Declaration, getCombinedModifierFlags, isParameterPropertyDeclaration, isVariableDeclaration, ModifierFlags, getCombinedNodeFlags, NodeFlags, VariableDeclarationList, isLiteralExpression, isIdentifier, BindingPattern, isSourceFile, SyntaxKind, findAncestor, SourceFile, EntityNameOrEntityNameExpression, isBindingElement, isVariableStatement, SymbolFlags, __String, ImportClause, ImportEqualsDeclaration, ImportSpecifier, NamespaceImport, isFunctionLike, getNameOfDeclaration, DeclarationName, isElementAccessExpression, isPropertyAccessExpression, FunctionLikeDeclaration, CompilerOptions, isGetAccessor, isSetAccessor, ResolutionMode } from "typescript"; +import { Debug } from "./debug"; +import { BasicSymbol, bindSourceFile } from "./emit-binder"; +import { appendIfUnique, emptyArray, every, filter } from "./lang-utils"; +import { EmitResolver, LateBoundDeclaration, LateVisibilityPaintedStatement, SymbolAccessibility, SymbolVisibilityResult, _Symbol } from "./types"; +import { isBindingPattern, isExternalModuleAugmentation, hasEffectiveModifier, getTextOfNode, hasSyntacticModifier, isInJSFile, isLateVisibilityPaintedStatement, isThisIdentifier, getFirstIdentifier, isPartOfTypeNode, AnyImportSyntax, hasDynamicName, skipParentheses, nodeIsPresent, isAmbientDeclaration } from "./utils"; + + +export function createEmitResolver(file: SourceFile, options: CompilerOptions, packageModuleType: ResolutionMode) { + + const { getNodeLinks, resolveName } = bindSourceFile(file, options, packageModuleType); + + + function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean { + if (isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConst(node)) { + // TODO: Make sure this is a valid approximation for literal types + return !node.type && 'initializer' in node && !!node.initializer && isLiteralExpression(node.initializer); + // Original TS version + // return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); + } + return false; + } + + + function isIdentifierComputedName(name: DeclarationName | undefined): boolean { + if (!name) return false; + if (!(name.kind === SyntaxKind.ComputedPropertyName || name.kind === SyntaxKind.ElementAccessExpression)) { + return false; + } + let expr= isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; + while(isPropertyAccessExpression(expr)) { + expr = expr.expression; + } + return isIdentifier(expr); + } + + return { + isDeclarationVisible, + isLiteralConstDeclaration, + createLiteralConstValue(node) { + return 'initializer' in node && node.initializer; + }, + isLateBound(node): node is LateBoundDeclaration { + const name = getNameOfDeclaration(node); + return !hasDynamicName(node) || isIdentifierComputedName(name) + }, + isImplementationOfOverload(node) { + function getSignaturesOfSymbol(symbol: BasicSymbol | undefined): Node[] { + if(!symbol) return emptyArray; + if(symbol.signatureDeclarations) return symbol.signatureDeclarations; + + if (!symbol || !symbol.declarations) return (symbol.signatureDeclarations = emptyArray); + const result: Node[] = symbol.signatureDeclarations = []; + for (let i = 0; i < symbol.declarations.length; i++) { + const decl = symbol.declarations[i]; + if (!isFunctionLike(decl) || isGetAccessor(decl) || isSetAccessor(decl)) { + // If non methods got merged in a class member bail with an empty array + // This is TS error behavior and we want to preserve iot as much as possible + // if(isClassElement(decl)) { + // return emptyArray; + // } + continue; + }; + // Don't include signature if node is the implementation of an overloaded function. A node is considered + // an implementation node if it has a body and the previous node is of the same kind and immediately + // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). + if (i > 0 && (decl as FunctionLikeDeclaration).body) { + const previous = symbol.declarations[i - 1]; + if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) { + continue; + } + } + // If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters. + // Exclude contextually-typed kinds because we already apply the @type tag to the context, plus applying it here to the initializer would supress checks that the two are compatible. + result.push(decl); + } + return result; + } + + + if (nodeIsPresent((node as FunctionLikeDeclaration).body)) { + if (isGetAccessor(node) || isSetAccessor(node)) return false; // Get or set accessors can never be overload implementations, but can have up to 2 signatures + const symbol = node.symbol; + const signaturesOfSymbol = getSignaturesOfSymbol(symbol as unknown as BasicSymbol); + // If this function body corresponds to function with multiple signature, it is implementation of overload + // e.g.: function foo(a: string): string; + // function foo(a: number): number; + // function foo(a: any) { // This is implementation of the overloads + // return a; + // } + return signaturesOfSymbol.length > 1 || + // If there is single signature for the symbol, it is overload if that signature isn't coming from the node + // e.g.: function foo(a: string): string; + // function foo(a: any) { // This is implementation of the overloads + // return a; + // } + (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0] !== node); + } + return false; + }, + isOptionalParameter(parameter) { + const signature = parameter.parent; + const paramIndex = signature.parameters.indexOf(parameter); + Debug.assert(paramIndex != -1); + if(parameter.questionToken) return true; + if(parameter.dotDotDotToken) return !!parameter.initializer; + + for(let i = paramIndex; i< signature.parameters.length; i++) { + const p = signature.parameters[i]; + if(!p.questionToken && !p.initializer && !p.dotDotDotToken) { + return false; + } + } + return true; + }, + isEntityNameVisible, + getTypeReferenceDirectivesForEntityName(name) { + return undefined; + }, + isExpandoFunctionDeclaration(){ + // Always return false, we don' support expando functions in isolatedDeclarations + return false; + }, + getSymbolOfExternalModuleSpecifier() { + return undefined; + }, + isImportRequiredByAugmentation() { + return false; + }, + } as Partial as EmitResolver + + + function isDeclarationReadonly(declaration: Declaration): boolean { + return !!(getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration, declaration.parent)); + } + + /** @internal */ + function isVarConst(node: VariableDeclaration | VariableDeclarationList): boolean { + return !!(getCombinedNodeFlags(node) & NodeFlags.Const); + } + + function isDeclarationVisible(node: Node): boolean { + if (node) { + const links = getNodeLinks(node); + if (links.isVisible === undefined) { + links.isVisible = links.symbol?.isVisible ?? !!determineIfDeclarationIsVisible(); + } + return links.isVisible; + } + + return false; + + function determineIfDeclarationIsVisible() { + switch (node.kind) { + case SyntaxKind.JSDocCallbackTag: + case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JSDocEnumTag: + // Top-level jsdoc type aliases are considered exported + // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file + return !!(node.parent && node.parent.parent && node.parent.parent.parent && isSourceFile(node.parent.parent.parent)); + case SyntaxKind.BindingElement: + return isDeclarationVisible(node.parent.parent); + case SyntaxKind.VariableDeclaration: + if (isBindingPattern((node as VariableDeclaration).name) && + !((node as VariableDeclaration).name as BindingPattern).elements.length) { + // If the binding pattern is empty, this variable declaration is not visible + return false; + } + // falls through + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + // external module augmentation is always visible + if (isExternalModuleAugmentation(node)) { + return true; + } + const parent = getDeclarationContainer(node); + // If the node is not exported or it is not ambient module element (except import declaration) + if (!(getCombinedModifierFlags(node as Declaration) & ModifierFlags.Export) && + !(node.kind !== SyntaxKind.ImportEqualsDeclaration && parent.kind !== SyntaxKind.SourceFile && isAmbientDeclaration(parent))) { + return isGlobalSourceFile(parent); + } + // Exported members/ambient module elements (exception import declaration) are visible if parent is visible + return isDeclarationVisible(parent); + + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (hasEffectiveModifier(node, ModifierFlags.Private | ModifierFlags.Protected)) { + // Private/protected properties/methods are not visible + return false; + } + // Public properties/methods are visible if its parents are visible, so: + // falls through + + case SyntaxKind.Constructor: + case SyntaxKind.ConstructSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.IndexSignature: + case SyntaxKind.Parameter: + case SyntaxKind.ModuleBlock: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + case SyntaxKind.TypeLiteral: + case SyntaxKind.TypeReference: + case SyntaxKind.ArrayType: + case SyntaxKind.TupleType: + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: + case SyntaxKind.ParenthesizedType: + case SyntaxKind.NamedTupleMember: + return isDeclarationVisible(node.parent); + + // Default binding, import specifier and namespace import is visible + // only on demand so by default it is not visible + case SyntaxKind.ImportClause: + case SyntaxKind.NamespaceImport: + case SyntaxKind.ImportSpecifier: + return false; + + // Type parameters are always visible + case SyntaxKind.TypeParameter: + + // Source file and namespace export are always visible + // falls through + case SyntaxKind.SourceFile: + case SyntaxKind.NamespaceExportDeclaration: + return true; + + // Export assignments do not create name bindings outside the module + case SyntaxKind.ExportAssignment: + return false; + + default: + return false; + } + } + } + + function hasVisibleDeclarations(symbol: BasicSymbol, shouldComputeAliasToMakeVisible: boolean): SymbolVisibilityResult | undefined { + let aliasesToMakeVisible: LateVisibilityPaintedStatement[] | undefined; + if (!every(filter(symbol.declarations, d => d.kind !== SyntaxKind.Identifier), getIsDeclarationVisible)) { + return undefined; + } + return { accessibility: SymbolAccessibility.Accessible, aliasesToMakeVisible }; + + function getIsDeclarationVisible(declaration: Declaration) { + if (!isDeclarationVisible(declaration)) { + // Mark the unexported alias as visible if its parent is visible + // because these kind of aliases can be used to name types in declaration file + + const anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !hasSyntacticModifier(anyImportSyntax, ModifierFlags.Export) && // import clause without export + isDeclarationVisible(anyImportSyntax.parent)) { + return addVisibleAlias(declaration, anyImportSyntax); + } + else if (isVariableDeclaration(declaration) && isVariableStatement(declaration.parent.parent) && + !hasSyntacticModifier(declaration.parent.parent, ModifierFlags.Export) && // unexported variable statement + isDeclarationVisible(declaration.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent); + } + else if (isLateVisibilityPaintedStatement(declaration) // unexported top-level statement + && !hasSyntacticModifier(declaration, ModifierFlags.Export) + && isDeclarationVisible(declaration.parent)) { + return addVisibleAlias(declaration, declaration); + } + else if (isBindingElement(declaration)) { + if (symbol.flags & SymbolFlags.Alias && isInJSFile(declaration) && declaration.parent?.parent // exported import-like top-level JS require statement + && isVariableDeclaration(declaration.parent.parent) + && declaration.parent.parent.parent?.parent && isVariableStatement(declaration.parent.parent.parent.parent) + && !hasSyntacticModifier(declaration.parent.parent.parent.parent, ModifierFlags.Export) + && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) + && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + } + else if (symbol.flags & SymbolFlags.BlockScopedVariable) { + const variableStatement = findAncestor(declaration, isVariableStatement)!; + if (hasSyntacticModifier(variableStatement, ModifierFlags.Export)) { + return true; + } + if (!isDeclarationVisible(variableStatement.parent)) { + return false; + } + return addVisibleAlias(declaration, variableStatement); + } + } + + // Declaration is not visible + return false; + } + + return true; + } + + function addVisibleAlias(declaration: Declaration, aliasingStatement: LateVisibilityPaintedStatement) { + // In function "buildTypeDisplay" where we decide whether to write type-alias or serialize types, + // we want to just check if type- alias is accessible or not but we don't care about emitting those alias at that time + // since we will do the emitting later in trackSymbol. + if (shouldComputeAliasToMakeVisible) { + getNodeLinks(declaration).isVisible = true; + aliasesToMakeVisible = appendIfUnique(aliasesToMakeVisible, aliasingStatement); + } + return true; + } + } + + function isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult { + // get symbol of the first identifier of the entityName + let meaning: SymbolFlags; + if (entityName.parent.kind === SyntaxKind.TypeQuery || + entityName.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === SyntaxKind.ComputedPropertyName) { + // Typeof value + meaning = SymbolFlags.Value | SymbolFlags.ExportValue; + } + else if (entityName.kind === SyntaxKind.QualifiedName || entityName.kind === SyntaxKind.PropertyAccessExpression || + entityName.parent.kind === SyntaxKind.ImportEqualsDeclaration) { + // Left identifier from type reference or TypeAlias + // Entity name of the import declaration + meaning = SymbolFlags.Namespace; + } + else { + // Type Reference or TypeAlias entity = Identifier + meaning = SymbolFlags.Type; + } + const firstIdentifier = getFirstIdentifier(entityName); + const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning); + if (symbol && symbol.flags & SymbolFlags.TypeParameter && meaning & SymbolFlags.Type) { + return { accessibility: SymbolAccessibility.Accessible }; + } + if (!symbol && isThisIdentifier(firstIdentifier) + // TODO: isolatedDeclarations: Just assume this is accessible + // && isSymbolAccessible(getSymbolOfNode(getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === SymbolAccessibility.Accessible + ) { + // TODO: isolatedDeclarations: Is this ever hit for declarations ? + // debugger; + return { accessibility: SymbolAccessibility.Accessible }; + } + + // Verify if the symbol is accessible + return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { + // TODO: isolatedDeclarations: In TS this would be an inaccessible symbol, but TS will give errors we just transform + // We don't actually keep enough information for full accessibility, + // We just do this to mark accessible imports + accessibility: SymbolAccessibility.Accessible, + errorSymbolName: getTextOfNode(firstIdentifier), + errorNode: firstIdentifier + }; + } +} + +/** @internal */ +export function getRootDeclaration(node: Node): Node { + while (node.kind === SyntaxKind.BindingElement) { + node = node.parent.parent; + } + return node; +} + +function getDeclarationContainer(node: Node): Node { + return findAncestor(getRootDeclaration(node), node => { + switch (node.kind) { + case SyntaxKind.VariableDeclaration: + case SyntaxKind.VariableDeclarationList: + case SyntaxKind.ImportSpecifier: + case SyntaxKind.NamedImports: + case SyntaxKind.NamespaceImport: + case SyntaxKind.ImportClause: + return false; + default: + return true; + } + })!.parent; +} + +// Isolated declarations never support global source files. +function isGlobalSourceFile(node: Node) { + return isSourceFile(node) && !isExternalModule(node); +} +export function isExternalModule(file: SourceFile): boolean { + return file.externalModuleIndicator !== undefined; +} + +function getAnyImportSyntax(node: Node): AnyImportSyntax | undefined { + switch (node.kind) { + case SyntaxKind.ImportEqualsDeclaration: + return node as ImportEqualsDeclaration; + case SyntaxKind.ImportClause: + return (node as ImportClause).parent; + case SyntaxKind.NamespaceImport: + return (node as NamespaceImport).parent.parent; + case SyntaxKind.ImportSpecifier: + return (node as ImportSpecifier).parent.parent.parent; + default: + return undefined; + } +} diff --git a/external-declarations/src/compiler/lang-utils.ts b/external-declarations/src/compiler/lang-utils.ts new file mode 100644 index 0000000000000..d73d66117c17e --- /dev/null +++ b/external-declarations/src/compiler/lang-utils.ts @@ -0,0 +1,945 @@ +import { MapLike, SortedArray, SortedReadonlyArray } from "typescript"; + + +export type Mutable = { -readonly [K in keyof T]: T[K] }; + + +/** @internal */ +export type EqualityComparer = (a: T, b: T) => boolean; + +/** @internal */ +export type Comparer = (a: T, b: T) => Comparison; + +export function forEach(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined { + if (array) { + for (let i = 0; i < array.length; i++) { + const result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; +} + + + +/** @internal */ +export function concatenate(array1: T[], array2: T[]): T[]; +/** @internal */ +export function concatenate(array1: readonly T[], array2: readonly T[]): readonly T[]; +/** @internal */ +export function concatenate(array1: T[] | undefined, array2: T[] | undefined): T[]; +/** @internal */ +export function concatenate(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[]; +/** @internal */ +export function concatenate(array1: undefined | readonly T[], array2: undefined | readonly T[]): undefined | T[] | readonly T[] { + if (!some(array2)) return array1; + if (!some(array1)) return array2; + return [...array1, ...array2]; +} + + +/** @internal */ +export function some(array: readonly T[] | undefined): array is readonly T[]; +/** @internal */ +export function some(array: readonly T[] | undefined, predicate: (value: T) => boolean): boolean; +/** @internal */ +export function some(array: readonly T[] | undefined, predicate?: (value: T) => boolean): boolean { + if (array) { + if (predicate) { + for (const v of array) { + if (predicate(v)) { + return true; + } + } + } + else { + return array.length > 0; + } + } + return false; +} + + +/** @internal */ +export function stringContains(str: string, substring: string): boolean { + return str.indexOf(substring) !== -1; +} + + +/** + * Filters an array by a predicate function. Returns the same array instance if the predicate is + * true for all elements, otherwise returns a new array instance containing the filtered subset. + * + * @internal + */ + export function filter(array: T[], f: (x: T) => x is U): U[]; + /** @internal */ + export function filter(array: T[], f: (x: T) => boolean): T[]; + /** @internal */ + export function filter(array: readonly T[], f: (x: T) => x is U): readonly U[]; + /** @internal */ + export function filter(array: readonly T[], f: (x: T) => boolean): readonly T[]; + /** @internal */ + export function filter(array: T[] | undefined, f: (x: T) => x is U): U[] | undefined; + /** @internal */ + export function filter(array: T[] | undefined, f: (x: T) => boolean): T[] | undefined; + /** @internal */ + export function filter(array: readonly T[] | undefined, f: (x: T) => x is U): readonly U[] | undefined; + /** @internal */ + export function filter(array: readonly T[] | undefined, f: (x: T) => boolean): readonly T[] | undefined; + /** @internal */ + export function filter(array: readonly T[] | undefined, f: (x: T) => boolean): readonly T[] | undefined { + if (array) { + const len = array.length; + let i = 0; + while (i < len && f(array[i])) i++; + if (i < len) { + const result = array.slice(0, i); + i++; + while (i < len) { + const item = array[i]; + if (f(item)) { + result.push(item); + } + i++; + } + return result; + } + } + return array; + } + + /** + * @return Whether the value was added. + * + * @internal + */ +export function pushIfUnique(array: T[], toAdd: T, equalityComparer?: EqualityComparer): boolean { + if (contains(array, toAdd, equalityComparer)) { + return false; + } + else { + array.push(toAdd); + return true; + } +} + +/** @internal */ +export function contains(array: readonly T[] | undefined, value: T, equalityComparer: EqualityComparer = equateValues): boolean { + if (array) { + for (const v of array) { + if (equalityComparer(v, value)) { + return true; + } + } + } + return false; +} + + +/** @internal */ +export const enum Comparison { + LessThan = -1, + EqualTo = 0, + GreaterThan = 1 +} +export function equateValues(a: T, b: T) { + return a === b; +} + +/** @internal */ +export function length(array: readonly any[] | undefined): number { + return array ? array.length : 0; +} + + +/** + * Flattens an array containing a mix of array or non-array elements. + * + * @param array The array to flatten. + * + * @internal + */ + export function flatten(array: T[][] | readonly (T | readonly T[] | undefined)[]): T[] { + const result: T[] = []; + for (const v of array) { + if (v) { + if (isArray(v)) { + addRange(result, v); + } + else { + result.push(v); + } + } + } + return result; +} + + + +/** + * Tests whether a value is an array. + * + * @internal + */ + export function isArray(value: any): value is readonly unknown[] { + return Array.isArray ? Array.isArray(value) : value instanceof Array; +} + + + + +/** + * Appends a range of value to an array, returning the array. + * + * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array + * is created if `value` was appended. + * @param from The values to append to the array. If `from` is `undefined`, nothing is + * appended. If an element of `from` is `undefined`, that element is not appended. + * @param start The offset in `from` at which to start copying values. + * @param end The offset in `from` at which to stop copying values (non-inclusive). + * + * @internal + */ + export function addRange(to: T[], from: readonly T[] | undefined, start?: number, end?: number): T[]; + /** @internal */ + export function addRange(to: T[] | undefined, from: readonly T[] | undefined, start?: number, end?: number): T[] | undefined; + /** @internal */ + export function addRange(to: T[] | undefined, from: readonly T[] | undefined, start?: number, end?: number): T[] | undefined { + if (from === undefined || from.length === 0) return to; + if (to === undefined) return from.slice(start, end); + start = start === undefined ? 0 : toOffset(from, start); + end = end === undefined ? from.length : toOffset(from, end); + for (let i = start; i < end && i < from.length; i++) { + if (from[i] !== undefined) { + to.push(from[i]); + } + } + return to; + } + +/** + * Gets the actual offset into an array for a relative offset. Negative offsets indicate a + * position offset from the end of the array. + */ +function toOffset(array: readonly any[], offset: number) { + return offset < 0 ? array.length + offset : offset; +} + + +/** @internal */ +export function map(array: readonly T[], f: (x: T, i: number) => U): U[]; +/** @internal */ +export function map(array: readonly T[] | undefined, f: (x: T, i: number) => U): U[] | undefined; +/** @internal */ +export function map(array: readonly T[] | undefined, f: (x: T, i: number) => U): U[] | undefined { + let result: U[] | undefined; + if (array) { + result = []; + for (let i = 0; i < array.length; i++) { + result.push(f(array[i], i)); + } + } + return result; +} + + + +/** + * Compacts an array, removing any falsey elements. + * + * @internal + */ + export function compact(array: (T | undefined | null | false | 0 | "")[]): T[]; + /** @internal */ + export function compact(array: readonly (T | undefined | null | false | 0 | "")[]): readonly T[]; + // ESLint thinks these can be combined with the above - they cannot; they'd produce higher-priority inferences and prevent the falsey types from being stripped + /** @internal */ + export function compact(array: T[]): T[]; // eslint-disable-line @typescript-eslint/unified-signatures + /** @internal */ + export function compact(array: readonly T[]): readonly T[]; // eslint-disable-line @typescript-eslint/unified-signatures + /** @internal */ + export function compact(array: T[]): T[] { + let result: T[] | undefined; + if (array) { + for (let i = 0; i < array.length; i++) { + const v = array[i]; + if (result || !v) { + if (!result) { + result = array.slice(0, i); + } + if (v) { + result.push(v); + } + } + } + } + return result || array; + } + + +/** + * Maps an array. If the mapped value is an array, it is spread into the result. + * + * @param array The array to map. + * @param mapfn The callback used to map the result into one or more values. + * + * @internal + */ + export function flatMap(array: readonly T[] | undefined, mapfn: (x: T, i: number) => U | readonly U[] | undefined): readonly U[] { + let result: U[] | undefined; + if (array) { + for (let i = 0; i < array.length; i++) { + const v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + result = addRange(result, v); + } + else { + result = append(result, v); + } + } + } + } + return result || emptyArray; +} + +/** @internal */ +export const emptyArray: never[] = [] as never[]; + + + +/** + * Appends a value to an array, returning the array. + * + * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array + * is created if `value` was appended. + * @param value The value to append to the array. If `value` is `undefined`, nothing is + * appended. + * + * @internal + */ + export function append[number] | undefined>(to: TArray, value: TValue): [undefined, undefined] extends [TArray, TValue] ? TArray : NonNullable[number][]; + /** @internal */ + export function append(to: T[], value: T | undefined): T[]; + /** @internal */ + export function append(to: T[] | undefined, value: T): T[]; + /** @internal */ + export function append(to: T[] | undefined, value: T | undefined): T[] | undefined; + /** @internal */ + export function append(to: Push, value: T | undefined): void; + /** @internal */ + export function append(to: T[], value: T | undefined): T[] | undefined { + if (value === undefined) return to; + if (to === undefined) return [value]; + to.push(value); + return to; + } + +/** Array that is only intended to be pushed to, never read. */ +export interface Push { + push(...values: T[]): void; + /** @internal */ readonly length: number; +} + + +/** + * Stable sort of an array. Elements equal to each other maintain their relative position in the array. + * + * @internal + */ + export function stableSort(array: readonly T[], comparer: Comparer): SortedReadonlyArray { + const indices = indicesOf(array); + stableSortIndices(array, indices, comparer); + return indices.map(i => array[i]) as SortedArray as SortedReadonlyArray; +} +function selectIndex(_: unknown, i: number) { + return i; +} + +function stableSortIndices(array: readonly T[], indices: number[], comparer: Comparer) { + // sort indices by value then position + indices.sort((x, y) => comparer(array[x], array[y]) || compareValues(x, y)); +} + +/** + * Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. + * + * @internal + */ + export function find(array: readonly T[] | undefined, predicate: (element: T, index: number) => element is U, startIndex?: number): U | undefined; + /** @internal */ + export function find(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): T | undefined; + /** @internal */ + export function find(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): T | undefined { + if (array === undefined) return undefined; + for (let i = startIndex ?? 0; i < array.length; i++) { + const value = array[i]; + if (predicate(value, i)) { + return value; + } + } + return undefined; + } + + +/** + * Returns the last element of an array if non-empty, `undefined` otherwise. + * + * @internal + */ + export function lastOrUndefined(array: readonly T[] | undefined): T | undefined { + return array === undefined || array.length === 0 ? undefined : array[array.length - 1]; +} + +/** @internal */ +export function last(array: readonly T[]): T { + return array[array.length - 1]; +} + +/** @internal */ +export function indicesOf(array: readonly unknown[]): number[] { + return array.map(selectIndex); +} + +/** @internal */ +export function findLastIndex(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): number { + if (array === undefined) return -1; + for (let i = startIndex ?? array.length - 1; i >= 0; i--) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; +} + +/** + * Compare the equality of two strings using a case-sensitive ordinal comparison. + * + * Case-sensitive comparisons compare both strings one code-point at a time using the integer + * value of each code-point after applying `toUpperCase` to each string. We always map both + * strings to their upper-case form as some unicode characters do not properly round-trip to + * lowercase (such as `ẞ` (German sharp capital s)). + * + * @internal + */ + export function equateStringsCaseInsensitive(a: string, b: string) { + return a === b + || a !== undefined + && b !== undefined + && a.toUpperCase() === b.toUpperCase(); +} + +/** + * Compare the equality of two strings using a case-sensitive ordinal comparison. + * + * Case-sensitive comparisons compare both strings one code-point at a time using the + * integer value of each code-point. + * + * @internal + */ + export function equateStringsCaseSensitive(a: string, b: string) { + return equateValues(a, b); +} + +function compareComparableValues(a: string | undefined, b: string | undefined): Comparison; +function compareComparableValues(a: number | undefined, b: number | undefined): Comparison; +function compareComparableValues(a: string | number | undefined, b: string | number | undefined) { + return a === b ? Comparison.EqualTo : + a === undefined ? Comparison.LessThan : + b === undefined ? Comparison.GreaterThan : + a < b ? Comparison.LessThan : + Comparison.GreaterThan; +} + +/** + * Compare two numeric values for their order relative to each other. + * To compare strings, use any of the `compareStrings` functions. + * + * @internal + */ +export function compareValues(a: number | undefined, b: number | undefined): Comparison { + return compareComparableValues(a, b); +} + + +/** + * Compare two strings using a case-insensitive ordinal comparison. + * + * Ordinal comparisons are based on the difference between the unicode code points of both + * strings. Characters with multiple unicode representations are considered unequal. Ordinal + * comparisons provide predictable ordering, but place "a" after "B". + * + * Case-insensitive comparisons compare both strings one code-point at a time using the integer + * value of each code-point after applying `toUpperCase` to each string. We always map both + * strings to their upper-case form as some unicode characters do not properly round-trip to + * lowercase (such as `ẞ` (German sharp capital s)). + * + * @internal + */ + export function compareStringsCaseInsensitive(a: string, b: string) { + if (a === b) return Comparison.EqualTo; + if (a === undefined) return Comparison.LessThan; + if (b === undefined) return Comparison.GreaterThan; + a = a.toUpperCase(); + b = b.toUpperCase(); + return a < b ? Comparison.LessThan : a > b ? Comparison.GreaterThan : Comparison.EqualTo; +} + +/** + * Compare two strings using a case-sensitive ordinal comparison. + * + * Ordinal comparisons are based on the difference between the unicode code points of both + * strings. Characters with multiple unicode representations are considered unequal. Ordinal + * comparisons provide predictable ordering, but place "a" after "B". + * + * Case-sensitive comparisons compare both strings one code-point at a time using the integer + * value of each code-point. + * + * @internal + */ + export function compareStringsCaseSensitive(a: string | undefined, b: string | undefined): Comparison { + return compareComparableValues(a, b); +} + +/** @internal */ +export function getStringComparer(ignoreCase?: boolean) { + return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive; +} + + +/** + * Iterates through `array` by index and performs the callback on each element of array until the callback + * returns a falsey value, then returns false. + * If no such value is found, the callback is applied to each element of array and `true` is returned. + * + * @internal + */ + export function every(array: readonly T[] | undefined, callback: (element: T, index: number) => boolean): boolean { + if (array) { + for (let i = 0; i < array.length; i++) { + if (!callback(array[i], i)) { + return false; + } + } + } + + return true; +} + + +/** @internal */ +export function mapDefined(array: readonly T[] | undefined, mapFn: (x: T, i: number) => U | undefined): U[] { + const result: U[] = []; + if (array) { + for (let i = 0; i < array.length; i++) { + const mapped = mapFn(array[i], i); + if (mapped !== undefined) { + result.push(mapped); + } + } + } + return result; +} + + +/** + * Shims `Array.from`. + * + * @internal + */ + export function arrayFrom(iterator: Iterator | IterableIterator, map: (t: T) => U): U[]; + /** @internal */ + export function arrayFrom(iterator: Iterator | IterableIterator): T[]; + /** @internal */ + export function arrayFrom(iterator: Iterator | IterableIterator, map?: (t: T) => U): (T | U)[] { + const result: (T | U)[] = []; + for (let iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) { + result.push(map ? map(iterResult.value) : iterResult.value); + } + return result; + } + + /** @internal */ +export function startsWith(str: string, prefix: string): boolean { + return str.lastIndexOf(prefix, 0) === 0; +} + + +/** @internal */ +export function endsWith(str: string, suffix: string): boolean { + const expectedPos = str.length - suffix.length; + return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; +} + +/** @internal */ +export function removeSuffix(str: string, suffix: string): string { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str; +} + +/** @internal */ +export function tryRemoveSuffix(str: string, suffix: string): string | undefined { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined; +} + + +/** + * Returns lower case string + * + * @internal + */ + export function toLowerCase(x: string) { + return x.toLowerCase(); +} + + +/** + * Returns its argument. + * + * @internal + */ + export function identity(x: T) { + return x; +} + + +/** + * Remove an item from an array, moving everything to its right one space left. + * + * @internal + */ + export function orderedRemoveItem(array: T[], item: T): boolean { + for (let i = 0; i < array.length; i++) { + if (array[i] === item) { + orderedRemoveItemAt(array, i); + return true; + } + } + return false; +} + + +/** + * Remove an item by index from an array, moving everything to its right one space left. + * + * @internal + */ + export function orderedRemoveItemAt(array: T[], index: number): void { + // This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`. + for (let i = index; i < array.length - 1; i++) { + array[i] = array[i + 1]; + } + array.pop(); +} + +export function getEntries(obj: MapLike): [string, T][] { + return obj ? _entries(obj) : []; +} + +const _entries = Object.entries || ((obj: MapLike) => { + const keys = getOwnKeys(obj); + const result: [string, T][] = Array(keys.length); + for (let i = 0; i < keys.length; i++) { + result[i] = [keys[i], obj[keys[i]]]; + } + return result; +}); + +const hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Gets the owned, enumerable property keys of a map-like. + * + * @internal + */ + export function getOwnKeys(map: MapLike): string[] { + const keys: string[] = []; + for (const key in map) { + if (hasOwnProperty.call(map, key)) { + keys.push(key); + } + } + + return keys; +} + +/** @internal */ +export function tryCast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined; +/** @internal */ +export function tryCast(value: T, test: (value: T) => boolean): T | undefined; +/** @internal */ +export function tryCast(value: T, test: (value: T) => boolean): T | undefined { + return value !== undefined && test(value) ? value : undefined; +} + + +/** + * Like `forEach`, but suitable for use with numbers and strings (which may be falsy). + * + * @internal + */ + export function firstDefined(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined { + if (array === undefined) { + return undefined; + } + + for (let i = 0; i < array.length; i++) { + const result = callback(array[i], i); + if (result !== undefined) { + return result; + } + } + return undefined; +} + +/** + * True is greater than false. + * + * @internal + */ + export function compareBooleans(a: boolean, b: boolean): Comparison { + return compareValues(a ? 1 : 0, b ? 1 : 0); +} + +/** + * Tests whether a value is string + * + * @internal + */ + export function isString(text: unknown): text is string { + return typeof text === "string"; +} +/** @internal */ +export function isNumber(x: unknown): x is number { + return typeof x === "number"; +} + + +/** + * patternOrStrings contains both patterns (containing "*") and regular strings. + * Return an exact match if possible, or a pattern match, or undefined. + * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) + * + * @internal + */ + export function matchPatternOrExact(patternOrStrings: readonly (string | Pattern)[], candidate: string): string | Pattern | undefined { + const patterns: Pattern[] = []; + for (const patternOrString of patternOrStrings) { + if (patternOrString === candidate) { + return candidate; + } + + if (!isString(patternOrString)) { + patterns.push(patternOrString); + } + } + + return findBestPatternMatch(patterns, _ => _, candidate); +} + +/** + * Represents a "prefix*suffix" pattern. + * + * @internal + */ + export interface Pattern { + prefix: string; + suffix: string; +} + + +/** + * Return the object corresponding to the best pattern to match `candidate`. + * + * @internal + */ + export function findBestPatternMatch(values: readonly T[], getPattern: (value: T) => Pattern, candidate: string): T | undefined { + let matchedValue: T | undefined; + // use length of prefix as betterness criteria + let longestMatchPrefixLength = -1; + + for (const v of values) { + const pattern = getPattern(v); + if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = pattern.prefix.length; + matchedValue = v; + } + } + + return matchedValue; +} + +/** @internal */ +export function isPatternMatch({ prefix, suffix }: Pattern, candidate: string) { + return candidate.length >= prefix.length + suffix.length && + startsWith(candidate, prefix) && + endsWith(candidate, suffix); +} + +/** @internal */ +export function tryParsePatterns(paths: MapLike): (string | Pattern)[] { + return mapDefined(getOwnKeys(paths), path => tryParsePattern(path)); +} +/** + * Returns the input if there are no stars, a pattern if there is exactly one, + * and undefined if there are more. + * + * @internal + */ +export function tryParsePattern(pattern: string): string | Pattern | undefined { + const indexOfStar = pattern.indexOf("*"); + if (indexOfStar === -1) { + return pattern; + } + return pattern.indexOf("*", indexOfStar + 1) !== -1 + ? undefined + : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; +} + + +/** @internal */ +export function min(items: readonly [T, ...T[]], compare: Comparer): T; +/** @internal */ +export function min(items: readonly T[], compare: Comparer): T | undefined; +/** @internal */ +export function min(items: readonly T[], compare: Comparer): T | undefined { + return reduceLeft(items, (x, y) => compare(x, y) === Comparison.LessThan ? x : y); +} + +/** @internal */ +export function reduceLeft(array: readonly T[] | undefined, f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; +/** @internal */ +export function reduceLeft(array: readonly T[], f: (memo: T, value: T, i: number) => T): T | undefined; +/** @internal */ +export function reduceLeft(array: T[], f: (memo: T, value: T, i: number) => T, initial?: T, start?: number, count?: number): T | undefined { + if (array && array.length > 0) { + const size = array.length; + if (size > 0) { + let pos = start === undefined || start < 0 ? 0 : start; + const end = count === undefined || pos + count > size - 1 ? size - 1 : pos + count; + let result: T; + if (arguments.length <= 2) { + result = array[pos]; + pos++; + } + else { + result = initial!; + } + while (pos <= end) { + result = f(result, array[pos], pos); + pos++; + } + return result; + } + } + return initial; +} + +export const trimString = (s: string) => s.trim(); + +/** + * Unlike `pushIfUnique`, this can take `undefined` as an input, and returns a new array. + * + * @internal + */ + export function appendIfUnique(array: T[] | undefined, toAdd: T, equalityComparer?: EqualityComparer): T[] { + if (array) { + pushIfUnique(array, toAdd, equalityComparer); + return array; + } + else { + return [toAdd]; + } +} + +export function isNullOrUndefined(x: any): x is null | undefined { + return x === undefined || x === null; // eslint-disable-line no-null/no-null +} + + +/** + * Performs a binary search, finding the index at which `value` occurs in `array`. + * If no such index is found, returns the 2's-complement of first index at which + * `array[index]` exceeds `value`. + * @param array A sorted array whose first element must be no larger than number + * @param value The value to be searched for in the array. + * @param keySelector A callback used to select the search key from `value` and each element of + * `array`. + * @param keyComparer A callback used to compare two keys in a sorted array. + * @param offset An offset into `array` at which to start the search. + * + * @internal + */ + export function binarySearch(array: readonly T[], value: T, keySelector: (v: T) => U, keyComparer: Comparer, offset?: number): number { + return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset); +} + +/** + * Performs a binary search, finding the index at which an object with `key` occurs in `array`. + * If no such index is found, returns the 2's-complement of first index at which + * `array[index]` exceeds `key`. + * @param array A sorted array whose first element must be no larger than number + * @param key The key to be searched for in the array. + * @param keySelector A callback used to select the search key from each element of `array`. + * @param keyComparer A callback used to compare two keys in a sorted array. + * @param offset An offset into `array` at which to start the search. + * + * @internal + */ +export function binarySearchKey(array: readonly T[], key: U, keySelector: (v: T, i: number) => U, keyComparer: Comparer, offset?: number): number { + if (!some(array)) { + return -1; + } + + let low = offset || 0; + let high = array.length - 1; + while (low <= high) { + const middle = low + ((high - low) >> 1); + const midKey = keySelector(array[middle], middle); + switch (keyComparer(midKey, key)) { + case Comparison.LessThan: + low = middle + 1; + break; + case Comparison.EqualTo: + return middle; + case Comparison.GreaterThan: + high = middle - 1; + break; + } + } + + return ~low; +} + + +/** + * Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. + * + * @internal + */ + export function findIndex(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): number { + if (array === undefined) return -1; + for (let i = startIndex ?? 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; +} + + +/** @internal */ +export function clone(object: T): T { + const result: any = {}; + for (const id in object) { + if (hasOwnProperty.call(object, id)) { + result[id] = (object as any)[id]; + } + } + return result; +} \ No newline at end of file diff --git a/external-declarations/src/compiler/path-utils.ts b/external-declarations/src/compiler/path-utils.ts new file mode 100644 index 0000000000000..1e7e8f3e0a0f8 --- /dev/null +++ b/external-declarations/src/compiler/path-utils.ts @@ -0,0 +1,1097 @@ +import { Extension, Path } from "typescript"; +import { Debug } from "./debug"; +import { stringContains, identity, startsWith, equateStringsCaseSensitive, some, Comparison, compareValues, endsWith, lastOrUndefined, equateStringsCaseInsensitive, compareStringsCaseInsensitive, compareStringsCaseSensitive, getStringComparer, toLowerCase } from "./lang-utils"; +import { CharacterCodes, GetCanonicalFileName } from "./types"; + +/** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + * + * @internal + */ +export const directorySeparator = "/"; +/** @internal */ +export const altDirectorySeparator = "\\"; +const urlSchemeSeparator = "://"; +const backslashRegExp = /\\/g; + +//// Path Tests + +/** + * Determines whether a charCode corresponds to `/` or `\`. + * + * @internal + */ +export function isAnyDirectorySeparator(charCode: number): boolean { + return charCode === CharacterCodes.slash || charCode === CharacterCodes.backslash; +} + +/** + * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.). + * + * @internal + */ +export function isUrl(path: string) { + return getEncodedRootLength(path) < 0; +} + +/** + * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path + * like `c:`, `c:\` or `c:/`). + * + * @internal + */ +export function isRootedDiskPath(path: string) { + return getEncodedRootLength(path) > 0; +} + +/** + * Determines whether a path consists only of a path root. + * + * @internal + */ +export function isDiskPathRoot(path: string) { + const rootLength = getEncodedRootLength(path); + return rootLength > 0 && rootLength === path.length; +} + +/** + * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.). + * + * ```ts + * // POSIX + * pathIsAbsolute("/path/to/file.ext") === true + * // DOS + * pathIsAbsolute("c:/path/to/file.ext") === true + * // URL + * pathIsAbsolute("file:///path/to/file.ext") === true + * // Non-absolute + * pathIsAbsolute("path/to/file.ext") === false + * pathIsAbsolute("./path/to/file.ext") === false + * ``` + * + * @internal + */ +export function pathIsAbsolute(path: string): boolean { + return getEncodedRootLength(path) !== 0; +} + +/** + * Determines whether a path starts with a relative path component (i.e. `.` or `..`). + * + * @internal + */ +export function pathIsRelative(path: string): boolean { + return /^\.\.?($|[\\/])/.test(path); +} + +/** + * Determines whether a path is neither relative nor absolute, e.g. "path/to/file". + * Also known misleadingly as "non-relative". + * + * @internal + */ +export function pathIsBareSpecifier(path: string): boolean { + return !pathIsAbsolute(path) && !pathIsRelative(path); +} + +/** @internal */ +export function hasExtension(fileName: string): boolean { + return stringContains(getBaseFileName(fileName), "."); +} + +/** @internal */ +export function fileExtensionIs(path: string, extension: string): boolean { + return path.length > extension.length && endsWith(path, extension); +} + +/** @internal */ +export function fileExtensionIsOneOf(path: string, extensions: readonly string[]): boolean { + for (const extension of extensions) { + if (fileExtensionIs(path, extension)) { + return true; + } + } + + return false; +} + +/** + * Determines whether a path has a trailing separator (`/` or `\\`). + * + * @internal + */ +export function hasTrailingDirectorySeparator(path: string) { + return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); +} + +//// Path Parsing + +function isVolumeCharacter(charCode: number) { + return (charCode >= CharacterCodes.a && charCode <= CharacterCodes.z) || + (charCode >= CharacterCodes.A && charCode <= CharacterCodes.Z); +} + +function getFileUrlVolumeSeparatorEnd(url: string, start: number) { + const ch0 = url.charCodeAt(start); + if (ch0 === CharacterCodes.colon) return start + 1; + if (ch0 === CharacterCodes.percent && url.charCodeAt(start + 1) === CharacterCodes._3) { + const ch2 = url.charCodeAt(start + 2); + if (ch2 === CharacterCodes.a || ch2 === CharacterCodes.A) return start + 3; + } + return -1; +} + +/** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * If the root is part of a URL, the twos-complement of the root length is returned. + */ +function getEncodedRootLength(path: string): number { + if (!path) return 0; + const ch0 = path.charCodeAt(0); + + // POSIX or UNC + if (ch0 === CharacterCodes.slash || ch0 === CharacterCodes.backslash) { + if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") + + const p1 = path.indexOf(ch0 === CharacterCodes.slash ? directorySeparator : altDirectorySeparator, 2); + if (p1 < 0) return path.length; // UNC: "//server" or "\\server" + + return p1 + 1; // UNC: "//server/" or "\\server\" + } + + // DOS + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === CharacterCodes.colon) { + const ch2 = path.charCodeAt(2); + if (ch2 === CharacterCodes.slash || ch2 === CharacterCodes.backslash) return 3; // DOS: "c:/" or "c:\" + if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") + } + + // URL + const schemeEnd = path.indexOf(urlSchemeSeparator); + if (schemeEnd !== -1) { + const authorityStart = schemeEnd + urlSchemeSeparator.length; + const authorityEnd = path.indexOf(directorySeparator, authorityStart); + if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" + // For local "file" URLs, include the leading DOS volume (if present). + // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a + // special case interpreted as "the machine from which the URL is being interpreted". + const scheme = path.slice(0, schemeEnd); + const authority = path.slice(authorityStart, authorityEnd); + if (scheme === "file" && (authority === "" || authority === "localhost") && + isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { + const volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); + if (volumeSeparatorEnd !== -1) { + if (path.charCodeAt(volumeSeparatorEnd) === CharacterCodes.slash) { + // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" + return ~(volumeSeparatorEnd + 1); + } + if (volumeSeparatorEnd === path.length) { + // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" + // but not "file:///c:d" or "file:///c%3ad" + return ~volumeSeparatorEnd; + } + } + } + return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" + } + return ~path.length; // URL: "file://server", "http://server" + } + + // relative + return 0; +} + +/** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * + * For example: + * ```ts + * getRootLength("a") === 0 // "" + * getRootLength("/") === 1 // "/" + * getRootLength("c:") === 2 // "c:" + * getRootLength("c:d") === 0 // "" + * getRootLength("c:/") === 3 // "c:/" + * getRootLength("c:\\") === 3 // "c:\\" + * getRootLength("//server") === 7 // "//server" + * getRootLength("//server/share") === 8 // "//server/" + * getRootLength("\\\\server") === 7 // "\\\\server" + * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" + * getRootLength("file:///path") === 8 // "file:///" + * getRootLength("file:///c:") === 10 // "file:///c:" + * getRootLength("file:///c:d") === 8 // "file:///" + * getRootLength("file:///c:/path") === 11 // "file:///c:/" + * getRootLength("file://server") === 13 // "file://server" + * getRootLength("file://server/path") === 14 // "file://server/" + * getRootLength("http://server") === 13 // "http://server" + * getRootLength("http://server/path") === 14 // "http://server/" + * ``` + * + * @internal + */ +export function getRootLength(path: string) { + const rootLength = getEncodedRootLength(path); + return rootLength < 0 ? ~rootLength : rootLength; +} + +/** + * Returns the path except for its basename. Semantics align with NodeJS's `path.dirname` + * except that we support URLs as well. + * + * ```ts + * // POSIX + * getDirectoryPath("/path/to/file.ext") === "/path/to" + * getDirectoryPath("/path/to/") === "/path" + * getDirectoryPath("/") === "/" + * // DOS + * getDirectoryPath("c:/path/to/file.ext") === "c:/path/to" + * getDirectoryPath("c:/path/to/") === "c:/path" + * getDirectoryPath("c:/") === "c:/" + * getDirectoryPath("c:") === "c:" + * // URL + * getDirectoryPath("http://typescriptlang.org/path/to/file.ext") === "http://typescriptlang.org/path/to" + * getDirectoryPath("http://typescriptlang.org/path/to") === "http://typescriptlang.org/path" + * getDirectoryPath("http://typescriptlang.org/") === "http://typescriptlang.org/" + * getDirectoryPath("http://typescriptlang.org") === "http://typescriptlang.org" + * ``` + * + * @internal + */ +export function getDirectoryPath(path: Path): Path; +/** + * Returns the path except for its basename. Semantics align with NodeJS's `path.dirname` + * except that we support URLs as well. + * + * ```ts + * // POSIX + * getDirectoryPath("/path/to/file.ext") === "/path/to" + * getDirectoryPath("/path/to/") === "/path" + * getDirectoryPath("/") === "/" + * // DOS + * getDirectoryPath("c:/path/to/file.ext") === "c:/path/to" + * getDirectoryPath("c:/path/to/") === "c:/path" + * getDirectoryPath("c:/") === "c:/" + * getDirectoryPath("c:") === "c:" + * // URL + * getDirectoryPath("http://typescriptlang.org/path/to/file.ext") === "http://typescriptlang.org/path/to" + * getDirectoryPath("http://typescriptlang.org/path/to") === "http://typescriptlang.org/path" + * getDirectoryPath("http://typescriptlang.org/") === "http://typescriptlang.org/" + * getDirectoryPath("http://typescriptlang.org") === "http://typescriptlang.org" + * getDirectoryPath("file://server/path/to/file.ext") === "file://server/path/to" + * getDirectoryPath("file://server/path/to") === "file://server/path" + * getDirectoryPath("file://server/") === "file://server/" + * getDirectoryPath("file://server") === "file://server" + * getDirectoryPath("file:///path/to/file.ext") === "file:///path/to" + * getDirectoryPath("file:///path/to") === "file:///path" + * getDirectoryPath("file:///") === "file:///" + * getDirectoryPath("file://") === "file://" + * ``` + * + * @internal + */ +export function getDirectoryPath(path: string): string; +/** @internal */ +export function getDirectoryPath(path: string): string { + path = normalizeSlashes(path); + + // If the path provided is itself the root, then return it. + const rootLength = getRootLength(path); + if (rootLength === path.length) return path; + + // return the leading portion of the path up to the last (non-terminal) directory separator + // but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + return path.slice(0, Math.max(rootLength, path.lastIndexOf(directorySeparator))); +} + +/** + * Returns the path except for its containing directory name. + * Semantics align with NodeJS's `path.basename` except that we support URL's as well. + * + * ```ts + * // POSIX + * getBaseFileName("/path/to/file.ext") === "file.ext" + * getBaseFileName("/path/to/") === "to" + * getBaseFileName("/") === "" + * // DOS + * getBaseFileName("c:/path/to/file.ext") === "file.ext" + * getBaseFileName("c:/path/to/") === "to" + * getBaseFileName("c:/") === "" + * getBaseFileName("c:") === "" + * // URL + * getBaseFileName("http://typescriptlang.org/path/to/file.ext") === "file.ext" + * getBaseFileName("http://typescriptlang.org/path/to/") === "to" + * getBaseFileName("http://typescriptlang.org/") === "" + * getBaseFileName("http://typescriptlang.org") === "" + * getBaseFileName("file://server/path/to/file.ext") === "file.ext" + * getBaseFileName("file://server/path/to/") === "to" + * getBaseFileName("file://server/") === "" + * getBaseFileName("file://server") === "" + * getBaseFileName("file:///path/to/file.ext") === "file.ext" + * getBaseFileName("file:///path/to/") === "to" + * getBaseFileName("file:///") === "" + * getBaseFileName("file://") === "" + * ``` + * + * @internal + */ +export function getBaseFileName(path: string): string; +/** + * Gets the portion of a path following the last (non-terminal) separator (`/`). + * Semantics align with NodeJS's `path.basename` except that we support URL's as well. + * If the base name has any one of the provided extensions, it is removed. + * + * ```ts + * getBaseFileName("/path/to/file.ext", ".ext", true) === "file" + * getBaseFileName("/path/to/file.js", ".ext", true) === "file.js" + * getBaseFileName("/path/to/file.js", [".ext", ".js"], true) === "file" + * getBaseFileName("/path/to/file.ext", ".EXT", false) === "file.ext" + * ``` + * + * @internal + */ +export function getBaseFileName(path: string, extensions: string | readonly string[], ignoreCase: boolean): string; +/** @internal */ +export function getBaseFileName(path: string, extensions?: string | readonly string[], ignoreCase?: boolean) { + path = normalizeSlashes(path); + + // if the path provided is itself the root, then it has not file name. + const rootLength = getRootLength(path); + if (rootLength === path.length) return ""; + + // return the trailing portion of the path starting after the last (non-terminal) directory + // separator but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + const name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(directorySeparator) + 1)); + const extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; + return extension ? name.slice(0, name.length - extension.length) : name; +} + +function tryGetExtensionFromPath(path: string, extension: string, stringEqualityComparer: (a: string, b: string) => boolean) { + if (!startsWith(extension, ".")) extension = "." + extension; + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === CharacterCodes.dot) { + const pathExtension = path.slice(path.length - extension.length); + if (stringEqualityComparer(pathExtension, extension)) { + return pathExtension; + } + } +} + +function getAnyExtensionFromPathWorker(path: string, extensions: string | readonly string[], stringEqualityComparer: (a: string, b: string) => boolean) { + if (typeof extensions === "string") { + return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || ""; + } + for (const extension of extensions) { + const result = tryGetExtensionFromPath(path, extension, stringEqualityComparer); + if (result) return result; + } + return ""; +} + +/** + * Gets the file extension for a path. + * + * ```ts + * getAnyExtensionFromPath("/path/to/file.ext") === ".ext" + * getAnyExtensionFromPath("/path/to/file.ext/") === ".ext" + * getAnyExtensionFromPath("/path/to/file") === "" + * getAnyExtensionFromPath("/path/to.ext/file") === "" + * ``` + * + * @internal + */ +export function getAnyExtensionFromPath(path: string): string; +/** + * Gets the file extension for a path, provided it is one of the provided extensions. + * + * ```ts + * getAnyExtensionFromPath("/path/to/file.ext", ".ext", true) === ".ext" + * getAnyExtensionFromPath("/path/to/file.js", ".ext", true) === "" + * getAnyExtensionFromPath("/path/to/file.js", [".ext", ".js"], true) === ".js" + * getAnyExtensionFromPath("/path/to/file.ext", ".EXT", false) === "" + * + * @internal + */ +export function getAnyExtensionFromPath(path: string, extensions: string | readonly string[], ignoreCase: boolean): string; +/** @internal */ +export function getAnyExtensionFromPath(path: string, extensions?: string | readonly string[], ignoreCase?: boolean): string { + // Retrieves any string from the final "." onwards from a base file name. + // Unlike extensionFromPath, which throws an exception on unrecognized extensions. + if (extensions) { + return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? equateStringsCaseInsensitive : equateStringsCaseSensitive); + } + const baseFileName = getBaseFileName(path); + const extensionIndex = baseFileName.lastIndexOf("."); + if (extensionIndex >= 0) { + return baseFileName.substring(extensionIndex); + } + return ""; +} + +function pathComponents(path: string, rootLength: number) { + const root = path.substring(0, rootLength); + const rest = path.substring(rootLength).split(directorySeparator); + if (rest.length && !lastOrUndefined(rest)) rest.pop(); + return [root, ...rest]; +} + +/** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is not normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * // POSIX + * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"] + * getPathComponents("/path/to/") === ["/", "path", "to"] + * getPathComponents("/") === ["/"] + * // DOS + * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"] + * getPathComponents("c:/path/to/") === ["c:/", "path", "to"] + * getPathComponents("c:/") === ["c:/"] + * getPathComponents("c:") === ["c:"] + * // URL + * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"] + * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"] + * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"] + * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"] + * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"] + * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"] + * getPathComponents("file://server/") === ["file://server/"] + * getPathComponents("file://server") === ["file://server"] + * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"] + * getPathComponents("file:///path/to/") === ["file:///", "path", "to"] + * getPathComponents("file:///") === ["file:///"] + * getPathComponents("file://") === ["file://"] + * ``` + * + * @internal + */ +export function getPathComponents(path: string, currentDirectory = "") { + path = combinePaths(currentDirectory, path); + return pathComponents(path, getRootLength(path)); +} + +//// Path Formatting + +/** + * Formats a parsed path consisting of a root component (at index 0) and zero or more path + * segments (at indices > 0). + * + * ```ts + * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext" + * ``` + * + * @internal + */ +export function getPathFromPathComponents(pathComponents: readonly string[]) { + if (pathComponents.length === 0) return ""; + + const root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]); + return root + pathComponents.slice(1).join(directorySeparator); +} + +//// Path Normalization + +/** + * Normalize path separators, converting `\` into `/`. + * + * @internal + */ +export function normalizeSlashes(path: string): string { + return path.indexOf("\\") !== -1 + ? path.replace(backslashRegExp, directorySeparator) + : path; +} + +/** + * Reduce an array of path components to a more simplified path by navigating any + * `"."` or `".."` entries in the path. + * + * @internal + */ +export function reducePathComponents(components: readonly string[]) { + if (!some(components)) return []; + const reduced = [components[0]]; + for (let i = 1; i < components.length; i++) { + const component = components[i]; + if (!component) continue; + if (component === ".") continue; + if (component === "..") { + if (reduced.length > 1) { + if (reduced[reduced.length - 1] !== "..") { + reduced.pop(); + continue; + } + } + else if (reduced[0]) continue; + } + reduced.push(component); + } + return reduced; +} + +/** + * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. + * + * ```ts + * // Non-rooted + * combinePaths("path", "to", "file.ext") === "path/to/file.ext" + * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext" + * // POSIX + * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext" + * combinePaths("/path", "/to", "file.ext") === "/to/file.ext" + * // DOS + * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext" + * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext" + * // URL + * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext" + * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext" + * ``` + * + * @internal + */ +export function combinePaths(path: string, ...paths: (string | undefined)[]): string { + if (path) path = normalizeSlashes(path); + for (let relativePath of paths) { + if (!relativePath) continue; + relativePath = normalizeSlashes(relativePath); + if (!path || getRootLength(relativePath) !== 0) { + path = relativePath; + } + else { + path = ensureTrailingDirectorySeparator(path) + relativePath; + } + } + return path; +} + +/** + * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any + * `.` and `..` path components are resolved. Trailing directory separators are preserved. + * + * ```ts + * resolvePath("/path", "to", "file.ext") === "path/to/file.ext" + * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/" + * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext" + * ``` + * + * @internal + */ +export function resolvePath(path: string, ...paths: (string | undefined)[]): string { + return normalizePath(some(paths) ? combinePaths(path, ...paths) : normalizeSlashes(path)); +} + +/** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"] + * ``` + * + * @internal + */ +export function getNormalizedPathComponents(path: string, currentDirectory: string | undefined) { + return reducePathComponents(getPathComponents(path, currentDirectory)); +} + +/** @internal */ +export function getNormalizedAbsolutePath(fileName: string, currentDirectory: string | undefined) { + return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); +} + +/** @internal */ +export function normalizePath(path: string): string { + path = normalizeSlashes(path); + // Most paths don't require normalization + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + // Some paths only require cleanup of `/./` or leading `./` + const simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, ""); + if (simplified !== path) { + path = simplified; + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + } + // Other paths require full normalization + const normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); + return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; +} + +function getPathWithoutRoot(pathComponents: readonly string[]) { + if (pathComponents.length === 0) return ""; + return pathComponents.slice(1).join(directorySeparator); +} + +/** @internal */ +export function getNormalizedAbsolutePathWithoutRoot(fileName: string, currentDirectory: string | undefined) { + return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); +} + +/** @internal */ +export function toPath(fileName: string, basePath: string | undefined, getCanonicalFileName: (path: string) => string): Path { + const nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath) as Path; +} + +//// Path Mutation + +/** + * Removes a trailing directory separator from a path, if it does not already have one. + * + * ```ts + * removeTrailingDirectorySeparator("/path/to/file.ext") === "/path/to/file.ext" + * removeTrailingDirectorySeparator("/path/to/file.ext/") === "/path/to/file.ext" + * ``` + * + * @internal + */ +export function removeTrailingDirectorySeparator(path: Path): Path; +/** @internal */ +export function removeTrailingDirectorySeparator(path: string): string; +/** @internal */ +export function removeTrailingDirectorySeparator(path: string) { + if (hasTrailingDirectorySeparator(path)) { + return path.substr(0, path.length - 1); + } + + return path; +} + +/** + * Adds a trailing directory separator to a path, if it does not already have one. + * + * ```ts + * ensureTrailingDirectorySeparator("/path/to/file.ext") === "/path/to/file.ext/" + * ensureTrailingDirectorySeparator("/path/to/file.ext/") === "/path/to/file.ext/" + * ``` + * + * @internal + */ +export function ensureTrailingDirectorySeparator(path: Path): Path; +/** @internal */ +export function ensureTrailingDirectorySeparator(path: string): string; +/** @internal */ +export function ensureTrailingDirectorySeparator(path: string) { + if (!hasTrailingDirectorySeparator(path)) { + return path + directorySeparator; + } + + return path; +} + +/** + * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed + * with `./` or `../`) so as not to be confused with an unprefixed module name. + * + * ```ts + * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext" + * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext" + * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext" + * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext" + * ``` + * + * @internal + */ +export function ensurePathIsNonModuleName(path: string): string { + return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path; +} + +/** + * Changes the extension of a path to the provided extension. + * + * ```ts + * changeAnyExtension("/path/to/file.ext", ".js") === "/path/to/file.js" + * ``` + * + * @internal + */ +export function changeAnyExtension(path: string, ext: string): string; +/** + * Changes the extension of a path to the provided extension if it has one of the provided extensions. + * + * ```ts + * changeAnyExtension("/path/to/file.ext", ".js", ".ext") === "/path/to/file.js" + * changeAnyExtension("/path/to/file.ext", ".js", ".ts") === "/path/to/file.ext" + * changeAnyExtension("/path/to/file.ext", ".js", [".ext", ".ts"]) === "/path/to/file.js" + * ``` + * + * @internal + */ +export function changeAnyExtension(path: string, ext: string, extensions: string | readonly string[], ignoreCase: boolean): string; +/** @internal */ +export function changeAnyExtension(path: string, ext: string, extensions?: string | readonly string[], ignoreCase?: boolean) { + const pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); + return pathext ? path.slice(0, path.length - pathext.length) + (startsWith(ext, ".") ? ext : "." + ext) : path; +} + +//// Path Comparisons + +// check path for these segments: '', '.'. '..' +const relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; + +function comparePathsWorker(a: string, b: string, componentComparer: (a: string, b: string) => Comparison) { + if (a === b) return Comparison.EqualTo; + if (a === undefined) return Comparison.LessThan; + if (b === undefined) return Comparison.GreaterThan; + + // NOTE: Performance optimization - shortcut if the root segments differ as there would be no + // need to perform path reduction. + const aRoot = a.substring(0, getRootLength(a)); + const bRoot = b.substring(0, getRootLength(b)); + const result = compareStringsCaseInsensitive(aRoot, bRoot); + if (result !== Comparison.EqualTo) { + return result; + } + + // NOTE: Performance optimization - shortcut if there are no relative path segments in + // the non-root portion of the path + const aRest = a.substring(aRoot.length); + const bRest = b.substring(bRoot.length); + if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { + return componentComparer(aRest, bRest); + } + + // The path contains a relative path segment. Normalize the paths and perform a slower component + // by component comparison. + const aComponents = reducePathComponents(getPathComponents(a)); + const bComponents = reducePathComponents(getPathComponents(b)); + const sharedLength = Math.min(aComponents.length, bComponents.length); + for (let i = 1; i < sharedLength; i++) { + const result = componentComparer(aComponents[i], bComponents[i]); + if (result !== Comparison.EqualTo) { + return result; + } + } + return compareValues(aComponents.length, bComponents.length); +} + +/** + * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively. + * + * @internal + */ +export function comparePathsCaseSensitive(a: string, b: string) { + return comparePathsWorker(a, b, compareStringsCaseSensitive); +} + +/** + * Performs a case-insensitive comparison of two paths. + * + * @internal + */ +export function comparePathsCaseInsensitive(a: string, b: string) { + return comparePathsWorker(a, b, compareStringsCaseInsensitive); +} + +/** + * Compare two paths using the provided case sensitivity. + * + * @internal + */ +export function comparePaths(a: string, b: string, ignoreCase?: boolean): Comparison; +/** @internal */ +export function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison; +/** @internal */ +export function comparePaths(a: string, b: string, currentDirectory?: string | boolean, ignoreCase?: boolean) { + if (typeof currentDirectory === "string") { + a = combinePaths(currentDirectory, a); + b = combinePaths(currentDirectory, b); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + return comparePathsWorker(a, b, getStringComparer(ignoreCase)); +} + +/** + * Determines whether a `parent` path contains a `child` path using the provide case sensitivity. + * + * @internal + */ +export function containsPath(parent: string, child: string, ignoreCase?: boolean): boolean; +/** @internal */ +export function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean; +/** @internal */ +export function containsPath(parent: string, child: string, currentDirectory?: string | boolean, ignoreCase?: boolean) { + if (typeof currentDirectory === "string") { + parent = combinePaths(currentDirectory, parent); + child = combinePaths(currentDirectory, child); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + if (parent === undefined || child === undefined) return false; + if (parent === child) return true; + const parentComponents = reducePathComponents(getPathComponents(parent)); + const childComponents = reducePathComponents(getPathComponents(child)); + if (childComponents.length < parentComponents.length) { + return false; + } + + const componentEqualityComparer = ignoreCase ? equateStringsCaseInsensitive : equateStringsCaseSensitive; + for (let i = 0; i < parentComponents.length; i++) { + const equalityComparer = i === 0 ? equateStringsCaseInsensitive : componentEqualityComparer; + if (!equalityComparer(parentComponents[i], childComponents[i])) { + return false; + } + } + + return true; +} + +/** + * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. + * Comparison is case-sensitive between the canonical paths. + * + * Use `containsPath` if file names are not already reduced and absolute. + * + * @internal + */ +export function startsWithDirectory(fileName: string, directoryName: string, getCanonicalFileName: GetCanonicalFileName): boolean { + const canonicalFileName = getCanonicalFileName(fileName); + const canonicalDirectoryName = getCanonicalFileName(directoryName); + return startsWith(canonicalFileName, canonicalDirectoryName + "/") || startsWith(canonicalFileName, canonicalDirectoryName + "\\"); +} + +//// Relative Paths + +/** @internal */ +export function getPathComponentsRelativeTo(from: string, to: string, stringEqualityComparer: (a: string, b: string) => boolean, getCanonicalFileName: GetCanonicalFileName) { + const fromComponents = reducePathComponents(getPathComponents(from)); + const toComponents = reducePathComponents(getPathComponents(to)); + + let start: number; + for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { + const fromComponent = getCanonicalFileName(fromComponents[start]); + const toComponent = getCanonicalFileName(toComponents[start]); + const comparer = start === 0 ? equateStringsCaseInsensitive : stringEqualityComparer; + if (!comparer(fromComponent, toComponent)) break; + } + + if (start === 0) { + return toComponents; + } + + const components = toComponents.slice(start); + const relative: string[] = []; + for (; start < fromComponents.length; start++) { + relative.push(".."); + } + return ["", ...relative, ...components]; +} + +/** + * Gets a relative path that can be used to traverse between `from` and `to`. + * + * @internal + */ +export function getRelativePathFromDirectory(from: string, to: string, ignoreCase: boolean): string; +/** + * Gets a relative path that can be used to traverse between `from` and `to`. + * + * @internal + */ +export function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileName: GetCanonicalFileName): string; // eslint-disable-line @typescript-eslint/unified-signatures +/** @internal */ +export function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileNameOrIgnoreCase: GetCanonicalFileName | boolean) { + Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); + const getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : identity; + const ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; + const pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? equateStringsCaseInsensitive : equateStringsCaseSensitive, getCanonicalFileName); + return getPathFromPathComponents(pathComponents); +} + +/** @internal */ +export function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); +} + +/** @internal */ +export function getRelativePathFromFile(from: string, to: string, getCanonicalFileName: GetCanonicalFileName) { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); +} + +/** @internal */ +export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: GetCanonicalFileName, isAbsolutePathAnUrl: boolean) { + const pathComponents = getPathComponentsRelativeTo( + resolvePath(currentDirectory, directoryPathOrUrl), + resolvePath(currentDirectory, relativeOrAbsolutePath), + equateStringsCaseSensitive, + getCanonicalFileName + ); + + const firstComponent = pathComponents[0]; + if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) { + const prefix = firstComponent.charAt(0) === directorySeparator ? "file://" : "file:///"; + pathComponents[0] = prefix + firstComponent; + } + + return getPathFromPathComponents(pathComponents); +} + +//// Path Traversal + +/** + * Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. + * + * @internal + */ +export function forEachAncestorDirectory(directory: Path, callback: (directory: Path) => T | undefined): T | undefined; +/** @internal */ +export function forEachAncestorDirectory(directory: string, callback: (directory: string) => T | undefined): T | undefined; +/** @internal */ +export function forEachAncestorDirectory(directory: Path, callback: (directory: Path) => T | undefined): T | undefined { + while (true) { + const result = callback(directory); + if (result !== undefined) { + return result; + } + + const parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + + directory = parentPath; + } +} + +/** @internal */ +export function isNodeModulesDirectory(dirPath: Path) { + return endsWith(dirPath, "/node_modules"); +} + + +/** + * Case insensitive file systems have descripencies in how they handle some characters (eg. turkish Upper case I with dot on top - \u0130) + * This function is used in places where we want to make file name as a key on these systems + * It is possible on mac to be able to refer to file name with I with dot on top as a fileName with its lower case form + * But on windows we cannot. Windows can have fileName with I with dot on top next to its lower case and they can not each be referred with the lowercase forms + * Technically we would want this function to be platform sepcific as well but + * our api has till now only taken caseSensitive as the only input and just for some characters we dont want to update API and ensure all customers use those api + * We could use upper case and we would still need to deal with the descripencies but + * we want to continue using lower case since in most cases filenames are lowercasewe and wont need any case changes and avoid having to store another string for the key + * So for this function purpose, we go ahead and assume character I with dot on top it as case sensitive since its very unlikely to use lower case form of that special character + * + * @internal + */ + export function toFileNameLowerCase(x: string) { + return fileNameLowerCaseRegExp.test(x) ? + x.replace(fileNameLowerCaseRegExp, toLowerCase) : + x; +} + + +// We convert the file names to lower case as key for file name on case insensitive file system +// While doing so we need to handle special characters (eg \u0130) to ensure that we dont convert +// it to lower case, fileName with its lowercase form can exist along side it. +// Handle special characters and make those case sensitive instead +// +// |-#--|-Unicode--|-Char code-|-Desc-------------------------------------------------------------------| +// | 1. | i | 105 | Ascii i | +// | 2. | I | 73 | Ascii I | +// |-------- Special characters ------------------------------------------------------------------------| +// | 3. | \u0130 | 304 | Upper case I with dot above | +// | 4. | i,\u0307 | 105,775 | i, followed by 775: Lower case of (3rd item) | +// | 5. | I,\u0307 | 73,775 | I, followed by 775: Upper case of (4th item), lower case is (4th item) | +// | 6. | \u0131 | 305 | Lower case i without dot, upper case is I (2nd item) | +// | 7. | \u00DF | 223 | Lower case sharp s | +// +// Because item 3 is special where in its lowercase character has its own +// upper case form we cant convert its case. +// Rest special characters are either already in lower case format or +// they have corresponding upper case character so they dont need special handling +// +// But to avoid having to do string building for most common cases, also ignore +// a-z, 0-9, \u0131, \u00DF, \, /, ., : and space +const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g; + +const extensionsToRemove = [Extension.Dts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Mts, Extension.Cjs, Extension.Cts, Extension.Ts, Extension.Js, Extension.Tsx, Extension.Jsx, Extension.Json]; +/** @internal */ +export function removeFileExtension(path: string): string { + for (const ext of extensionsToRemove) { + const extensionless = tryRemoveExtension(path, ext); + if (extensionless !== undefined) { + return extensionless; + } + } + return path; +} + + +/** @internal */ +export function tryRemoveExtension(path: string, extension: string): string | undefined { + return fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined; +} + + +/** @internal */ +export function removeExtension(path: string, extension: string): string { + return path.substring(0, path.length - extension.length); +} + +/** @internal */ +export function compareNumberOfDirectorySeparators(path1: string, path2: string) { + return compareValues( + numberOfDirectorySeparators(path1), + numberOfDirectorySeparators(path2) + ); +} +function numberOfDirectorySeparators(str: string) { + const match = str.match(/\//g); + return match ? match.length : 0; +} + +/** @internal */ +export const ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + +/** @internal */ +export function containsIgnoredPath(path: string) { + return some(ignoredPaths, p => stringContains(path, p)); +} + + +/** @internal */ +export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): GetCanonicalFileName { + return useCaseSensitiveFileNames ? identity : toFileNameLowerCase; +} + + +export function isSourceMapFile(f: string) { + return f.endsWith(".map"); +} +export function isJSONFile(f: string) { + return f.endsWith(Extension.Json); +} +export function isDeclarationFile(f: string) { + return f.endsWith(Extension.Dts) + || f.endsWith(Extension.Dmts) + || f.endsWith(Extension.Dcts); +} +export function isJavaScriptFile(f: string) { + return f.endsWith(Extension.Js) + || f.endsWith(Extension.Jsx) + || f.endsWith(Extension.Cjs) + || f.endsWith(Extension.Mjs); +} + + +export function getDeclarationExtension(path: string) { + return ( + path.endsWith(Extension.Mjs) || path.endsWith(Extension.Mts) ? Extension.Dmts: + path.endsWith(Extension.Cjs) || path.endsWith(Extension.Cts) ? Extension.Dcts: + Extension.Dts + ) +} \ No newline at end of file diff --git a/external-declarations/src/compiler/transform-file.ts b/external-declarations/src/compiler/transform-file.ts new file mode 100644 index 0000000000000..d119e4330498a --- /dev/null +++ b/external-declarations/src/compiler/transform-file.ts @@ -0,0 +1,45 @@ + +import * as ts from 'typescript' +import { transformDeclarations } from './declaration-emit'; +import { createEmitHost } from './emit-host'; +import { createEmitResolver } from './emit-resolver'; +import { TransformationContext } from './types'; + + + +export function transformFile(fileName: string, source: string, allProjectFiles: string[], tsLibFiles: string[], options: ts.CompilerOptions, moduleType: ts.ResolutionMode) { + + let sourceFile = ts.createSourceFile(fileName, source, options.target ?? ts.ScriptTarget.ES3, true, + fileName.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS); + const getCompilerOptions = () => options; + const emitResolver = createEmitResolver(sourceFile, options, moduleType); + const emitHost = createEmitHost(allProjectFiles, tsLibFiles, options); + const diagnostics: ts.Diagnostic[] = [] + const x = transformDeclarations({ + getEmitHost() { + return emitHost; + }, + getEmitResolver() { + return emitResolver; + }, + getCompilerOptions, + factory: ts.factory, + addDiagnostic(diag) { + diagnostics.push(diag) + }, + } as Partial as TransformationContext) + + let result = x(sourceFile); + + + const printer = ts.createPrinter({ + onlyPrintJsDocStyle: true, + newLine: options.newLine ?? ts.NewLineKind.CarriageReturnLineFeed, + target: options.target, + } as ts.PrinterOptions) + + return { + code: printer.printFile(result), + diagnostics, + }; +} diff --git a/external-declarations/src/compiler/transformer.ts b/external-declarations/src/compiler/transformer.ts new file mode 100644 index 0000000000000..33ec2033e285e --- /dev/null +++ b/external-declarations/src/compiler/transformer.ts @@ -0,0 +1,451 @@ +import { Node, NodeFactory, CompilerOptions, TransformerFactory, TransformationResult, SyntaxKind, VariableDeclaration, FunctionDeclaration, Statement, Identifier, EmitHelper, DiagnosticWithLocation, disposeEmitNodes, getParseTreeNode, SourceFile, isSourceFile, EmitFlags, EmitHint, setEmitFlags, NodeFlags } from "typescript"; +import { Debug } from "./debug"; +import { some, append } from "./lang-utils"; +import { EmitResolver, EmitHost, TransformationContext } from "./types"; +import { getEmitFlags, getSourceFileOfNode } from "./utils"; + +/** + * Transforms an array of SourceFiles by passing them through each transformer. + * + * @param resolver The emit resolver provided by the checker. + * @param host The emit host object used to interact with the file system. + * @param options Compiler options to surface in the `TransformationContext`. + * @param nodes An array of nodes to transform. + * @param transforms An array of `TransformerFactory` callbacks. + * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. + * + * @internal + */ + export function transformNodes(resolver: EmitResolver | undefined, host: EmitHost | undefined, factory: NodeFactory, options: CompilerOptions, nodes: readonly T[], transformers: readonly TransformerFactory[], allowDtsFiles: boolean): TransformationResult { + const enabledSyntaxKindFeatures = new Array(SyntaxKind.Count); + let lexicalEnvironmentVariableDeclarations: VariableDeclaration[]; + let lexicalEnvironmentFunctionDeclarations: FunctionDeclaration[]; + let lexicalEnvironmentStatements: Statement[]; + let lexicalEnvironmentFlags = LexicalEnvironmentFlags.None; + let lexicalEnvironmentVariableDeclarationsStack: VariableDeclaration[][] = []; + let lexicalEnvironmentFunctionDeclarationsStack: FunctionDeclaration[][] = []; + let lexicalEnvironmentStatementsStack: Statement[][] = []; + let lexicalEnvironmentFlagsStack: LexicalEnvironmentFlags[] = []; + let lexicalEnvironmentStackOffset = 0; + let lexicalEnvironmentSuspended = false; + let blockScopedVariableDeclarationsStack: Identifier[][] = []; + let blockScopeStackOffset = 0; + let blockScopedVariableDeclarations: Identifier[]; + let emitHelpers: EmitHelper[] | undefined; + let onSubstituteNode: TransformationContext["onSubstituteNode"] = noEmitSubstitution; + let onEmitNode: TransformationContext["onEmitNode"] = noEmitNotification; + let state = TransformationState.Uninitialized; + const diagnostics: DiagnosticWithLocation[] = []; + + // The transformation context is provided to each transformer as part of transformer + // initialization. + const context: TransformationContext = { + factory: factory as TransformationContext['factory'], + getCompilerOptions: () => options, + getEmitResolver: () => resolver!, // TODO: GH#18217 + getEmitHost: () => host!, // TODO: GH#18217 + startLexicalEnvironment, + suspendLexicalEnvironment, + resumeLexicalEnvironment, + endLexicalEnvironment, + hoistVariableDeclaration, + hoistFunctionDeclaration, + requestEmitHelper, + readEmitHelpers, + enableSubstitution, + enableEmitNotification, + isSubstitutionEnabled, + isEmitNotificationEnabled, + get onSubstituteNode() { return onSubstituteNode; }, + set onSubstituteNode(value) { + Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed."); + Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onSubstituteNode = value; + }, + get onEmitNode() { return onEmitNode; }, + set onEmitNode(value) { + Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed."); + Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onEmitNode = value; + }, + addDiagnostic(diag) { + console.log(diag.messageText); + }, + getEmitHelperFactory() { + return factory; + }, + }; + + // Ensure the parse tree is clean before applying transformations + for (const node of nodes) { + disposeEmitNodes(getSourceFileOfNode(getParseTreeNode(node))); + } + + + // Chain together and initialize each transformer. + const transformersWithContext = transformers.map(t => t(context)); + const transformation = (node: T): T => { + for (const transform of transformersWithContext) { + node = transform(node); + } + return node; + }; + + // prevent modification of transformation hooks. + state = TransformationState.Initialized; + + // Transform each node. + const transformed: T[] = []; + for (const node of nodes) { + transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); + } + + // prevent modification of the lexical environment. + state = TransformationState.Completed; + + return { + transformed, + substituteNode, + emitNodeWithNotification, + isEmitNotificationEnabled, + dispose, + diagnostics + }; + + function transformRoot(node: T) { + return node && (!isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node; + } + + /** + * Enables expression substitutions in the pretty printer for the provided SyntaxKind. + */ + function enableSubstitution(kind: SyntaxKind) { + Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= SyntaxKindFeatureFlags.Substitution; + } + + /** + * Determines whether expression substitutions are enabled for the provided node. + */ + function isSubstitutionEnabled(node: Node) { + return (enabledSyntaxKindFeatures[node.kind] & SyntaxKindFeatureFlags.Substitution) !== 0 + && (getEmitFlags(node) & EmitFlags.NoSubstitution) === 0; + } + + /** + * Emits a node with possible substitution. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emitCallback The callback used to emit the node or its substitute. + */ + function substituteNode(hint: EmitHint, node: Node) { + Debug.assert(state < TransformationState.Disposed, "Cannot substitute a node after the result is disposed."); + return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; + } + + /** + * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. + */ + function enableEmitNotification(kind: SyntaxKind) { + Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= SyntaxKindFeatureFlags.EmitNotifications; + } + + /** + * Determines whether before/after emit notifications should be raised in the pretty + * printer when it emits a node. + */ + function isEmitNotificationEnabled(node: Node) { + return (enabledSyntaxKindFeatures[node.kind] & SyntaxKindFeatureFlags.EmitNotifications) !== 0 + || (getEmitFlags(node) & EmitFlags.AdviseOnEmitNode) !== 0; + } + + /** + * Emits a node with possible emit notification. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emitCallback The callback used to emit the node. + */ + function emitNodeWithNotification(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) { + Debug.assert(state < TransformationState.Disposed, "Cannot invoke TransformationResult callbacks after the result is disposed."); + if (node) { + // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed + // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) + if (isEmitNotificationEnabled(node)) { + onEmitNode(hint, node, emitCallback); + } + else { + emitCallback(hint, node); + } + } + } + + /** + * Records a hoisted variable declaration for the provided name within a lexical environment. + */ + function hoistVariableDeclaration(name: Identifier): void { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); + const decl = setEmitFlags(factory.createVariableDeclaration(name), EmitFlags.NoNestedSourceMaps); + if (!lexicalEnvironmentVariableDeclarations) { + lexicalEnvironmentVariableDeclarations = [decl]; + } + else { + lexicalEnvironmentVariableDeclarations.push(decl); + } + if (lexicalEnvironmentFlags & LexicalEnvironmentFlags.InParameters) { + lexicalEnvironmentFlags |= LexicalEnvironmentFlags.VariablesHoistedInParameters; + } + } + + /** + * Records a hoisted function declaration within a lexical environment. + */ + function hoistFunctionDeclaration(func: FunctionDeclaration): void { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); + setEmitFlags(func, EmitFlags.CustomPrologue); + if (!lexicalEnvironmentFunctionDeclarations) { + lexicalEnvironmentFunctionDeclarations = [func]; + } + else { + lexicalEnvironmentFunctionDeclarations.push(func); + } + } + + /** + * Adds an initialization statement to the top of the lexical environment. + */ + function addInitializationStatement(node: Statement): void { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); + setEmitFlags(node, EmitFlags.CustomPrologue); + if (!lexicalEnvironmentStatements) { + lexicalEnvironmentStatements = [node]; + } + else { + lexicalEnvironmentStatements.push(node); + } + } + + /** + * Starts a new lexical environment. Any existing hoisted variable or function declarations + * are pushed onto a stack, and the related storage variables are reset. + */ + function startLexicalEnvironment(): void { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); + Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); + + // Save the current lexical environment. Rather than resizing the array we adjust the + // stack size variable. This allows us to reuse existing array slots we've + // already allocated between transformations to avoid allocation and GC overhead during + // transformation. + lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations; + lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations; + lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements; + lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags; + lexicalEnvironmentStackOffset++; + lexicalEnvironmentVariableDeclarations = undefined!; + lexicalEnvironmentFunctionDeclarations = undefined!; + lexicalEnvironmentStatements = undefined!; + lexicalEnvironmentFlags = LexicalEnvironmentFlags.None; + } + + /** Suspends the current lexical environment, usually after visiting a parameter list. */ + function suspendLexicalEnvironment(): void { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); + Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); + lexicalEnvironmentSuspended = true; + } + + /** Resumes a suspended lexical environment, usually before visiting a function body. */ + function resumeLexicalEnvironment(): void { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); + Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); + lexicalEnvironmentSuspended = false; + } + + /** + * Ends a lexical environment. The previous set of hoisted declarations are restored and + * any hoisted declarations added in this environment are returned. + */ + function endLexicalEnvironment(): Statement[] | undefined { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); + Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); + + let statements: Statement[] | undefined; + if (lexicalEnvironmentVariableDeclarations || + lexicalEnvironmentFunctionDeclarations || + lexicalEnvironmentStatements) { + if (lexicalEnvironmentFunctionDeclarations) { + statements = [...lexicalEnvironmentFunctionDeclarations]; + } + + if (lexicalEnvironmentVariableDeclarations) { + const statement = factory.createVariableStatement( + /*modifiers*/ undefined, + factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations) + ); + + setEmitFlags(statement, EmitFlags.CustomPrologue); + + if (!statements) { + statements = [statement]; + } + else { + statements.push(statement); + } + } + + if (lexicalEnvironmentStatements) { + if (!statements) { + statements = [...lexicalEnvironmentStatements]; + } + else { + statements = [...statements, ...lexicalEnvironmentStatements]; + } + } + } + + // Restore the previous lexical environment. + lexicalEnvironmentStackOffset--; + lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset]; + lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset]; + lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset]; + lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset]; + if (lexicalEnvironmentStackOffset === 0) { + lexicalEnvironmentVariableDeclarationsStack = []; + lexicalEnvironmentFunctionDeclarationsStack = []; + lexicalEnvironmentStatementsStack = []; + lexicalEnvironmentFlagsStack = []; + } + return statements; + } + + function setLexicalEnvironmentFlags(flags: LexicalEnvironmentFlags, value: boolean): void { + lexicalEnvironmentFlags = value ? + lexicalEnvironmentFlags | flags : + lexicalEnvironmentFlags & ~flags; + } + + function getLexicalEnvironmentFlags(): LexicalEnvironmentFlags { + return lexicalEnvironmentFlags; + } + + /** + * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. + */ + function startBlockScope() { + Debug.assert(state > TransformationState.Uninitialized, "Cannot start a block scope during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot start a block scope after transformation has completed."); + blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; + blockScopeStackOffset++; + blockScopedVariableDeclarations = undefined!; + } + + /** + * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. + */ + function endBlockScope() { + Debug.assert(state > TransformationState.Uninitialized, "Cannot end a block scope during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot end a block scope after transformation has completed."); + const statements: Statement[] | undefined = some(blockScopedVariableDeclarations) ? + [ + factory.createVariableStatement( + /*modifiers*/ undefined, + factory.createVariableDeclarationList( + blockScopedVariableDeclarations.map(identifier => factory.createVariableDeclaration(identifier)), + NodeFlags.Let + ) + ) + ] : undefined; + blockScopeStackOffset--; + blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; + if (blockScopeStackOffset === 0) { + blockScopedVariableDeclarationsStack = []; + } + return statements; + } + + function addBlockScopedVariable(name: Identifier): void { + Debug.assert(blockScopeStackOffset > 0, "Cannot add a block scoped variable outside of an iteration body."); + (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); + } + + function requestEmitHelper(helper: EmitHelper): void { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the transformation context during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed."); + Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); + if (helper.dependencies) { + for (const h of helper.dependencies) { + requestEmitHelper(h); + } + } + emitHelpers = append(emitHelpers, helper); + } + + function readEmitHelpers(): EmitHelper[] | undefined { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the transformation context during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed."); + const helpers = emitHelpers; + emitHelpers = undefined; + return helpers; + } + + function dispose() { + if (state < TransformationState.Disposed) { + // Clean up emit nodes on parse tree + for (const node of nodes) { + disposeEmitNodes(getSourceFileOfNode(getParseTreeNode(node))); + } + + // Release references to external entries for GC purposes. + lexicalEnvironmentVariableDeclarations = undefined!; + lexicalEnvironmentVariableDeclarationsStack = undefined!; + lexicalEnvironmentFunctionDeclarations = undefined!; + lexicalEnvironmentFunctionDeclarationsStack = undefined!; + onSubstituteNode = undefined!; + onEmitNode = undefined!; + emitHelpers = undefined; + + // Prevent further use of the transformation result. + state = TransformationState.Disposed; + } + } +} + +const enum TransformationState { + Uninitialized, + Initialized, + Completed, + Disposed +} + +const enum SyntaxKindFeatureFlags { + Substitution = 1 << 0, + EmitNotifications = 1 << 1, +} + + +/** @internal */ +export const enum LexicalEnvironmentFlags { + None = 0, + InParameters = 1 << 0, // currently visiting a parameter list + VariablesHoistedInParameters = 1 << 1 // a temp variable was hoisted while visiting a parameter list +} + +/** @internal */ +export function noEmitSubstitution(_hint: EmitHint, node: Node) { + return node; +} + +/** @internal */ +export function noEmitNotification(hint: EmitHint, node: Node, callback: (hint: EmitHint, node: Node) => void) { + callback(hint, node); +} \ No newline at end of file diff --git a/external-declarations/src/compiler/types.ts b/external-declarations/src/compiler/types.ts new file mode 100644 index 0000000000000..d764200e1251d --- /dev/null +++ b/external-declarations/src/compiler/types.ts @@ -0,0 +1,502 @@ +import { Symbol, ClassDeclaration, CompilerOptions, DeclarationName, DiagnosticWithLocation, EnumDeclaration, FunctionDeclaration, InterfaceDeclaration, ModuleDeclaration, ModuleKind, Node, PackageJsonInfoCache, Path, QualifiedName, SourceFile, SymbolFlags, TransformationContext as _TransformationContext, TypeAliasDeclaration, VariableStatement, NodeBuilderFlags, Statement, AccessorDeclaration, BindingElement, Declaration, ElementAccessExpression, EntityName, EntityNameOrEntityNameExpression, EnumMember, ExportDeclaration, Expression, Identifier, ImportCall, ImportDeclaration, ImportEqualsDeclaration, ImportTypeNode, ParameterDeclaration, PropertyAccessExpression, PropertyDeclaration, PropertySignature, SignatureDeclaration, StringLiteralLike, TypeNode, VariableDeclaration, VariableLikeDeclaration, ModuleBlock, LiteralTypeNode, BinaryExpression, ComputedPropertyName, NamedDeclaration, StringLiteral, ParenthesizedExpression, AsExpression, NonNullExpression, PartiallyEmittedExpression, SatisfiesExpression, TypeAssertion, EntityNameExpression, HasModifiers, Modifier, ModifierFlags, Program, UnparsedSource, FileReference, EmitFlags, EmitHelper, SourceMapRange, SynthesizedComment, TextRange, NoSubstitutionTemplateLiteral, MapLike } from "typescript"; +import { AllAccessorDeclarations, AnyImportSyntax, DiagnosticMessage } from "./utils"; + + +/** @internal */ +export interface ResolveModuleNameResolutionHost { + getCanonicalFileName(p: string): string; + getCommonSourceDirectory(): string; + getCurrentDirectory(): string; +} + + +export interface TransformationContext extends _TransformationContext { + addDiagnostic(diag: DiagnosticWithLocation): void; + /** @internal */ getEmitResolver(): EmitResolver; + /** @internal */ getEmitHost(): EmitHost; + /** @internal */ getEmitHelperFactory(): EmitHelperFactory; + factory: _TransformationContext['factory'] & { + updateModifiers(node: T, modifiers: readonly Modifier[] | ModifierFlags | undefined): T; + } +} + +export interface EmitHost extends ModuleSpecifierResolutionHost, ResolveModuleNameResolutionHost { + getCommonSourceDirectory(): string + getCompilerOptions(): CompilerOptions + getSourceFiles(): SourceFile[] + /** @internal */ getSourceFileFromReference(referencingFile: SourceFile | UnparsedSource, ref: FileReference): SourceFile | undefined; + /** @internal */ getLibFileFromReference(ref: FileReference): SourceFile | undefined; +} + +export interface EmitResolver { + hasGlobalName(name: string): boolean; + getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration | undefined; + getReferencedImportDeclaration(node: Identifier): Declaration | undefined; + getReferencedDeclarationWithCollidingName(node: Identifier): Declaration | undefined; + isDeclarationWithCollidingName(node: Declaration): boolean; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; + isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; + // getNodeCheckFlags(node: Node): NodeCheckFlags; + isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean; + isLateBound(node: Declaration): node is LateBoundDeclaration; + collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined; + isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined; + isRequiredInitializedParameter(node: ParameterDeclaration): boolean; + isOptionalUninitializedParameterProperty(node: ParameterDeclaration): boolean; + isExpandoFunctionDeclaration(node: FunctionDeclaration): boolean; + getPropertiesOfContainerFunction(node: Declaration): Symbol[]; + createTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration | PropertyAccessExpression, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker, addUndefined?: boolean): TypeNode | undefined; + createReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined; + createTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined; + createLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, tracker: SymbolTracker): Expression; + isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags | undefined, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; + isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; + // Returns the constant value this property access resolves to, or 'undefined' for a non-constant + getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined; + getReferencedValueDeclaration(reference: Identifier): Declaration | undefined; + // getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind; + isOptionalParameter(node: ParameterDeclaration): boolean; + moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; + isArgumentsLocalBinding(node: Identifier): boolean; + getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode | ImportCall): SourceFile | undefined; + getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): [specifier: string, mode: ResolutionMode | undefined][] | undefined; + getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): [specifier: string, mode: ResolutionMode | undefined][] | undefined; + isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; + getJsxFactoryEntity(location?: Node): EntityName | undefined; + getJsxFragmentFactoryEntity(location?: Node): EntityName | undefined; + getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations; + getSymbolOfExternalModuleSpecifier(node: StringLiteralLike): Symbol | undefined; + isBindingCapturedByNode(node: Node, decl: VariableDeclaration | BindingElement): boolean; + getDeclarationStatementsForSourceFile(node: SourceFile, flags: NodeBuilderFlags, tracker: SymbolTracker, bundled?: boolean): Statement[] | undefined; + isImportRequiredByAugmentation(decl: ImportDeclaration): boolean; +} +/** @internal */ +export interface AmbientModuleDeclaration extends ModuleDeclaration { + readonly body?: ModuleBlock; +} + +export interface EmitHelperFactory { + +} + +export type GetSymbolAccessibilityDiagnostic = (symbolAccessibilityResult: SymbolAccessibilityResult) => (SymbolAccessibilityDiagnostic | undefined); + +/** @internal */ +export interface SymbolAccessibilityDiagnostic { + errorNode: Node; + diagnosticMessage: DiagnosticMessage; + typeName?: DeclarationName | QualifiedName; +} + +export interface SymbolTracker { + // Called when the symbol writer encounters a symbol to write. Currently only used by the + // declaration emitter to help determine if it should patch up the final declaration file + // with import statements it previously saw (but chose not to emit). + trackSymbol?(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags): boolean; + reportInaccessibleThisError?(): void; + reportPrivateInBaseOfClassExpression?(propertyName: string): void; + reportInaccessibleUniqueSymbolError?(): void; + reportCyclicStructureError?(): void; + reportLikelyUnsafeImportRequiredError?(specifier: string): void; + reportTruncationError?(): void; + moduleResolverHost?: ModuleSpecifierResolutionHost & { getCommonSourceDirectory(): string }; + trackReferencedAmbientModule?(decl: ModuleDeclaration, symbol: Symbol): void; + trackExternalModuleSymbolOfImportTypeNode?(symbol: Symbol): void; + reportNonlocalAugmentation?(containingFile: SourceFile, parentSymbol: Symbol, augmentingSymbol: Symbol): void; + reportNonSerializableProperty?(propertyName: string): void; + reportImportTypeNodeResolutionModeOverride?(): void; +} + +/** @internal */ +export interface ModuleSpecifierResolutionHost { + useCaseSensitiveFileNames?(): boolean; + fileExists(path: string): boolean; + getCurrentDirectory(): string; + directoryExists?(path: string): boolean; + readFile?(path: string): string | undefined; + realpath?(path: string): string; + getPackageJsonInfoCache?(): PackageJsonInfoCache & { + /** @internal */ getPackageJsonInfo(packageJsonPath: string): PackageJsonInfo | boolean | undefined; + } | undefined; + getGlobalTypingsCacheLocation?(): string | undefined; + getNearestAncestorDirectoryWithPackageJson?(fileName: string, rootDir?: string): string | undefined; + + getProjectReferenceRedirect(fileName: string): string | undefined; + isSourceOfProjectReferenceRedirect(fileName: string): boolean; + + getSymlinkCache?(): { + getSymlinkedDirectoriesByRealpath(): MultiMap | undefined; + }; + readonly redirectTargetsMap: RedirectTargetsMap; +} + +export interface PackageJsonInfo { + packageDirectory: string; + contents: PackageJsonInfoContents; +} +/** @internal */ +export interface PackageJsonInfoContents { + packageJsonContent: PackageJsonPathFields; + versionPaths: VersionPaths | undefined; + /** false: resolved to nothing. undefined: not yet resolved */ + resolvedEntrypoints: string[] | false | undefined; +} +/** @internal */ +export interface VersionPaths { + version: string; + paths: MapLike; +} +export interface PackageJsonPathFields { + typings?: string; + types?: string; + typesVersions?: MapLike>; + main?: string; + tsconfig?: string; + type?: string; + imports?: object; + exports?: object; + name?: string; +} + + +export type RedirectTargetsMap = ReadonlyMap; + +export interface MultiMap extends Map { + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + add(key: K, value: V): V[]; + /** + * Removes a value from an array of values associated with the key. + * Does not preserve the order of those values. + * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. + */ + remove(key: K, value: V): void; +} + + +/** @internal */ +export interface SymbolAccessibilityResult extends SymbolVisibilityResult { + errorModuleName?: string; // If the symbol is not visible from module, module's name +} +/** @internal */ +export interface SymbolVisibilityResult { + accessibility: SymbolAccessibility; + aliasesToMakeVisible?: LateVisibilityPaintedStatement[]; // aliases that need to have this symbol visible + errorSymbolName?: string; // Optional symbol name that results in error + errorNode?: Node; // optional node that results in error +} + + +/** @internal */ +export const enum SymbolAccessibility { + Accessible, + NotAccessible, + CannotBeNamed +} + +/** @internal */ +export type LateVisibilityPaintedStatement = + | AnyImportSyntax + | VariableStatement + | ClassDeclaration + | FunctionDeclaration + | ModuleDeclaration + | TypeAliasDeclaration + | InterfaceDeclaration + | EnumDeclaration; + + +/** @internal */ +export type NodeId = number; + +export type ResolutionMode = ModuleKind.ESNext | ModuleKind.CommonJS | undefined; + + +/** @internal */ +export type GetCanonicalFileName = (fileName: string) => string; + + + +/** @internal */ +export const enum CharacterCodes { + nullCharacter = 0, + maxAsciiCharacter = 0x7F, + + lineFeed = 0x0A, // \n + carriageReturn = 0x0D, // \r + lineSeparator = 0x2028, + paragraphSeparator = 0x2029, + nextLine = 0x0085, + + // Unicode 3.0 space characters + space = 0x0020, // " " + nonBreakingSpace = 0x00A0, // + enQuad = 0x2000, + emQuad = 0x2001, + enSpace = 0x2002, + emSpace = 0x2003, + threePerEmSpace = 0x2004, + fourPerEmSpace = 0x2005, + sixPerEmSpace = 0x2006, + figureSpace = 0x2007, + punctuationSpace = 0x2008, + thinSpace = 0x2009, + hairSpace = 0x200A, + zeroWidthSpace = 0x200B, + narrowNoBreakSpace = 0x202F, + ideographicSpace = 0x3000, + mathematicalSpace = 0x205F, + ogham = 0x1680, + + _ = 0x5F, + $ = 0x24, + + _0 = 0x30, + _1 = 0x31, + _2 = 0x32, + _3 = 0x33, + _4 = 0x34, + _5 = 0x35, + _6 = 0x36, + _7 = 0x37, + _8 = 0x38, + _9 = 0x39, + + a = 0x61, + b = 0x62, + c = 0x63, + d = 0x64, + e = 0x65, + f = 0x66, + g = 0x67, + h = 0x68, + i = 0x69, + j = 0x6A, + k = 0x6B, + l = 0x6C, + m = 0x6D, + n = 0x6E, + o = 0x6F, + p = 0x70, + q = 0x71, + r = 0x72, + s = 0x73, + t = 0x74, + u = 0x75, + v = 0x76, + w = 0x77, + x = 0x78, + y = 0x79, + z = 0x7A, + + A = 0x41, + B = 0x42, + C = 0x43, + D = 0x44, + E = 0x45, + F = 0x46, + G = 0x47, + H = 0x48, + I = 0x49, + J = 0x4A, + K = 0x4B, + L = 0x4C, + M = 0x4D, + N = 0x4E, + O = 0x4F, + P = 0x50, + Q = 0x51, + R = 0x52, + S = 0x53, + T = 0x54, + U = 0x55, + V = 0x56, + W = 0x57, + X = 0x58, + Y = 0x59, + Z = 0x5a, + + ampersand = 0x26, // & + asterisk = 0x2A, // * + at = 0x40, // @ + backslash = 0x5C, // \ + backtick = 0x60, // ` + bar = 0x7C, // | + caret = 0x5E, // ^ + closeBrace = 0x7D, // } + closeBracket = 0x5D, // ] + closeParen = 0x29, // ) + colon = 0x3A, // : + comma = 0x2C, // , + dot = 0x2E, // . + doubleQuote = 0x22, // " + equals = 0x3D, // = + exclamation = 0x21, // ! + greaterThan = 0x3E, // > + hash = 0x23, // # + lessThan = 0x3C, // < + minus = 0x2D, // - + openBrace = 0x7B, // { + openBracket = 0x5B, // [ + openParen = 0x28, // ( + percent = 0x25, // % + plus = 0x2B, // + + question = 0x3F, // ? + semicolon = 0x3B, // ; + singleQuote = 0x27, // ' + slash = 0x2F, // / + tilde = 0x7E, // ~ + + backspace = 0x08, // \b + formFeed = 0x0C, // \f + byteOrderMark = 0xFEFF, + tab = 0x09, // \t + verticalTab = 0x0B, // \v +} + + +/** @internal */ +export type LiteralImportTypeNode = ImportTypeNode & { readonly argument: LiteralTypeNode & { readonly literal: StringLiteral } }; + + +/** @internal */ +export interface DynamicNamedDeclaration extends NamedDeclaration { + readonly name: ComputedPropertyName; +} + +/** @internal */ +export interface DynamicNamedBinaryExpression extends BinaryExpression { + readonly left: ElementAccessExpression; +} + + +/** @internal */ +export interface JSDocTypeAssertion extends ParenthesizedExpression { + readonly _jsDocTypeAssertionBrand: never; +} + +export type OuterExpression = ParenthesizedExpression | TypeAssertion | SatisfiesExpression | AsExpression | NonNullExpression | PartiallyEmittedExpression; + +/** @internal */ +export type AnyImportOrReExport = AnyImportSyntax | ExportDeclaration; + + +/** @internal */ +// A declaration that supports late-binding (used in checker) +export interface LateBoundDeclaration extends DynamicNamedDeclaration { + readonly name: LateBoundName; +} + +/** @internal */ +// A name that supports late-binding (used in checker) +export interface LateBoundName extends ComputedPropertyName { + readonly expression: EntityNameExpression; +} + + +/** @internal */ +export interface EmitFileNames { + jsFilePath?: string | undefined; + sourceMapFilePath?: string | undefined; + declarationFilePath?: string | undefined; + declarationMapPath?: string | undefined; + buildInfoPath?: string | undefined; +} + +export type _FileReference = FileReference + + +/** @internal */ +export type ExportedModulesFromDeclarationEmit = readonly Symbol[]; +export type _StringLiteralLike = StringLiteralLike + + +export type _Symbol = Symbol +export type _Path = Path +export type _ModifierFlags = ModifierFlags +declare module 'typescript' { + interface Node { + symbol: _Symbol; + emitNode?: EmitNode; + original: this; + modifierFlagsCache: _ModifierFlags + } + interface Symbol { + isReferenced: boolean; + parent: _Symbol; + } + interface Bundle { + /** @internal */ syntheticFileReferences?: readonly _FileReference[]; + /** @internal */ syntheticTypeReferences?: readonly _FileReference[]; + /** @internal */ syntheticLibReferences?: readonly _FileReference[]; + /** @internal */ hasNoDefaultLib?: boolean; + } + interface SourceFile { + exportedModulesFromDeclarationEmit?: ExportedModulesFromDeclarationEmit; + imports: readonly _StringLiteralLike[]; + path: _Path; + } + interface CompilerOptions { + /** + * The directory of the config file that specified 'paths'. Used to resolve relative paths when 'baseUrl' is absent. + * + * @internal + */ + pathsBasePath?: string; + configFilePath?: _Path; + } +} + + +/** @internal */ +export interface EmitNode { + annotatedNodes?: Node[]; // Tracks Parse-tree nodes with EmitNodes for eventual cleanup. + flags: EmitFlags; // Flags that customize emit + leadingComments?: SynthesizedComment[]; // Synthesized leading comments + trailingComments?: SynthesizedComment[]; // Synthesized trailing comments + commentRange?: TextRange; // The text range to use when emitting leading or trailing comments + sourceMapRange?: SourceMapRange; // The text range to use when emitting leading or trailing source mappings + tokenSourceMapRanges?: (SourceMapRange | undefined)[]; // The text range to use when emitting source mappings for tokens + constantValue?: string | number; // The constant value of an expression + externalHelpersModuleName?: Identifier; // The local name for an imported helpers module + externalHelpers?: boolean; + helpers?: EmitHelper[]; // Emit helpers for the node + startsOnNewLine?: boolean; // If the node should begin on a new line + snippetElement?: SnippetElement; // Snippet element of the node + typeNode?: TypeNode; // VariableDeclaration type +} + +/** @internal */ +export type SnippetElement = TabStop | Placeholder; + +/** @internal */ +export interface TabStop { + kind: SnippetKind.TabStop; + order: number; +} + +/** @internal */ +export interface Placeholder { + kind: SnippetKind.Placeholder; + order: number; +} +// Reference: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax +/** @internal */ +export const enum SnippetKind { + TabStop, // `$1`, `$2` + Placeholder, // `${1:foo}` + Choice, // `${1|one,two,three|}` + Variable, // `$name`, `${name:default}` +} + + + +/** @internal */ +export interface ModulePath { + path: string; + isInNodeModules: boolean; + isRedirect: boolean; +} \ No newline at end of file diff --git a/external-declarations/src/compiler/utils.ts b/external-declarations/src/compiler/utils.ts new file mode 100644 index 0000000000000..58a5747ca6307 --- /dev/null +++ b/external-declarations/src/compiler/utils.ts @@ -0,0 +1,1872 @@ +import { SourceFile, SyntaxKind, Node, TextSpan, DiagnosticWithLocation, DeclarationName, isPropertySignature, isBindingElement, isCallSignatureDeclaration, isConstructorDeclaration, isConstructSignatureDeclaration, isExpressionWithTypeArguments, isFunctionDeclaration, isGetAccessor, isImportEqualsDeclaration, isIndexSignatureDeclaration, isMethodDeclaration, isMethodSignature, isParameter, isPropertyAccessExpression, isPropertyDeclaration, isSetAccessor, isTypeAliasDeclaration, isTypeParameterDeclaration, isVariableDeclaration, QualifiedName, BindingElement, CallSignatureDeclaration, ConstructorDeclaration, ConstructSignatureDeclaration, ExpressionWithTypeArguments, FunctionDeclaration, GetAccessorDeclaration, ImportEqualsDeclaration, IndexSignatureDeclaration, JSDocCallbackTag, JSDocEnumTag, JSDocTypedefTag, MethodDeclaration, MethodSignature, ParameterDeclaration, PropertyAccessExpression, PropertyDeclaration, PropertySignature, SetAccessorDeclaration, TypeAliasDeclaration, TypeParameterDeclaration, VariableDeclaration, NamedDeclaration, NodeFlags, ClassLikeDeclaration, FunctionBody, ModifierFlags, getModifiers, ClassDeclaration, EnumDeclaration, InterfaceDeclaration, ModuleDeclaration, VariableStatement, ImportDeclaration, Visitor, AccessorDeclaration, SignatureDeclaration, Identifier, JSDocSignature, isJSDocSignature, getLeadingCommentRanges, Diagnostic, DiagnosticRelatedInformation, JsonSourceFile, ScriptKind, NodeFactory, Path, isModuleDeclaration, isSourceFile, Declaration, getNameOfDeclaration, isElementAccessExpression, BindingPattern, ImportTypeNode, isLiteralTypeNode, isStringLiteral, OuterExpressionKinds, Expression, isStringLiteralLike, isNumericLiteral, NumericLiteral, StringLiteralLike, getJSDocTypeTag, isParenthesizedExpression, EmitFlags, Statement, isExportAssignment, isExportDeclaration, JSDocContainer, HasJSDoc, JSDoc, Bundle, CompilerOptions, Extension, getTsBuildInfoEmitOutputFilePath, ImportCall, ExternalModuleReference, AssertClause, ModuleKind, EntityNameExpression, isIdentifier, PropertyAccessEntityNameExpression, ExportDeclaration, getJSDocAugmentsTag, HeritageClause, NodeArray, isClassElement, isClassStaticBlockDeclaration, isParseTreeNode, ModuleResolutionKind, JsxEmit, isPrefixUnaryExpression, PrefixUnaryExpression, canHaveModifiers, ModifierLike, getJSDocPublicTag, getJSDocPrivateTag, getJSDocProtectedTag, getJSDocOverrideTagNoCache, getJSDocReadonlyTag, getJSDocDeprecatedTag, ScriptTarget, FileExtensionInfo, EntityNameOrEntityNameExpression, isHeritageClause, CallExpression, FunctionLikeDeclaration, HasType, JSDocTemplateTag, TypeAssertion, TsConfigSourceFile, PrinterOptions, NewLineKind, sys, isVariableStatement, isLineBreak, isWhiteSpaceLike, identifierToKeywordKind } from "typescript"; +import { Debug } from "./debug"; +import { Diagnostics } from "./diagnosticInformationMap.generated"; +import { clone, Comparison, contains, emptyArray, find, flatten, identity, isArray, length, mapDefined, Mutable, some, startsWith, stringContains } from "./lang-utils"; +import { combinePaths, comparePaths, ensureTrailingDirectorySeparator, fileExtensionIs, fileExtensionIsOneOf, getNormalizedAbsolutePath, pathIsRelative, removeFileExtension } from "./path-utils"; +import { AmbientModuleDeclaration, AnyImportOrReExport, CharacterCodes, DynamicNamedBinaryExpression, DynamicNamedDeclaration, EmitFileNames, EmitHost, EmitNode, EmitResolver, GetCanonicalFileName, GetSymbolAccessibilityDiagnostic, JSDocTypeAssertion, LiteralImportTypeNode, ModuleSpecifierResolutionHost, OuterExpression, ResolveModuleNameResolutionHost, SymbolAccessibility, SymbolAccessibilityDiagnostic, SymbolAccessibilityResult } from "./types"; + + +export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan { + return { + start: node.pos, + length: node.end - node.pos + } +} + +export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): DiagnosticWithLocation { + const sourceFile = getSourceFileOfNode(node); + return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3); +} + +/** @internal */ +export function createDiagnosticForNodeInSourceFile(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): DiagnosticWithLocation { + const span = getErrorSpanForNode(sourceFile, node); + return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3); +} + +/** @internal */ +export function addRelatedInfo(diagnostic: T, ...relatedInformation: DiagnosticRelatedInformation[]): T { + if (!relatedInformation.length) { + return diagnostic; + } + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + Debug.assert(diagnostic.relatedInformation !== emptyArray, "Diagnostic had empty array singleton for related info, but is still being constructed!"); + diagnostic.relatedInformation.push(...relatedInformation); + return diagnostic; +} + +export interface DiagnosticMessage { + key: string; + category: DiagnosticCategory; + code: number; + message: string; + reportsUnnecessary?: {}; + reportsDeprecated?: {}; + /** @internal */ + elidedInCompatabilityPyramid?: boolean; +} + +export enum DiagnosticCategory { + Warning, + Error, + Suggestion, + Message +} + + +/** @internal */ +export function hasStaticModifier(node: Node): boolean { + return hasSyntacticModifier(node, ModifierFlags.Static); +} + +/** @internal */ +export function isStatic(node: Node) { + // https://tc39.es/ecma262/#sec-static-semantics-isstatic + return isClassElement(node) && hasStaticModifier(node) || isClassStaticBlockDeclaration(node); +} + +/** @internal */ +export function createGetSymbolAccessibilityDiagnosticForNodeName(node: DeclarationDiagnosticProducing) { + if (isSetAccessor(node) || isGetAccessor(node)) { + return getAccessorNameVisibilityError; + } + else if (isMethodSignature(node) || isMethodDeclaration(node)) { + return getMethodNameVisibilityError; + } + else { + return createGetSymbolAccessibilityDiagnosticForNode(node); + } + function getAccessorNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) { + const diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage, + errorNode: node, + typeName: (node as NamedDeclaration).name + } : undefined; + } + + function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { + if (isStatic(node)) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccessibilityResult.errorModuleName ? + Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + + function getMethodNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic | undefined { + const diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage, + errorNode: node, + typeName: (node as NamedDeclaration).name + } : undefined; + } + + function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { + if (isStatic(node)) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccessibilityResult.errorModuleName ? + Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1; + } + } +} + +/** @internal */ +export function getSourceFileOfNode(node: Node): SourceFile; +/** @internal */ +export function getSourceFileOfNode(node: Node | undefined): SourceFile | undefined; +/** @internal */ +export function getSourceFileOfNode(node: Node | undefined ): SourceFile | undefined { + while (node && node.kind !== SyntaxKind.SourceFile) { + node = node.parent; + } + return node as SourceFile; +} + + +/** @internal */ +export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number | undefined)[]): DiagnosticWithLocation; +/** @internal */ +export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): DiagnosticWithLocation { + + let text= message.message; + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); + } + + return { + file, + start, + length, + + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + reportsDeprecated: message.reportsDeprecated + }; +} + + +/** @internal */ +export function formatStringFromArgs(text: string, args: ArrayLike, baseIndex = 0): string { + return text.replace(/{(\d+)}/g, (_match, index: string) => "" + args[+index + baseIndex]); +} +export function declarationNameToString(name: DeclarationName | QualifiedName | undefined) { + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); +} + + +/** @internal */ +export function getTextOfNode(node: Node, includeTrivia = false): string { + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); +} + +/** @internal */ +export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string { + return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia); +} + + +/** @internal */ +export function getTextOfNodeFromSourceText(sourceText: string, node: Node, includeTrivia = false): string { + let text = sourceText.substring(node.pos, node.end); + return text; +} +/** @internal */ +export function getFullWidth(node: Node) { + return node.end - node.pos; +} + +/** @internal */ +export function canProduceDiagnostics(node: Node): node is DeclarationDiagnosticProducing { + return isVariableDeclaration(node) || + isPropertyDeclaration(node) || + isPropertySignature(node) || + isBindingElement(node) || + isSetAccessor(node) || + isGetAccessor(node) || + isConstructSignatureDeclaration(node) || + isCallSignatureDeclaration(node) || + isMethodDeclaration(node) || + isMethodSignature(node) || + isFunctionDeclaration(node) || + isParameter(node) || + isTypeParameterDeclaration(node) || + isExpressionWithTypeArguments(node) || + isImportEqualsDeclaration(node) || + isTypeAliasDeclaration(node) || + isConstructorDeclaration(node) || + isIndexSignatureDeclaration(node) || + isPropertyAccessExpression(node) || + isJSDocTypeAlias(node); +} + + + +export function isJSDocTypeAlias(node: Node): node is JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag { + return node.kind === SyntaxKind.JSDocTypedefTag || node.kind === SyntaxKind.JSDocCallbackTag || node.kind === SyntaxKind.JSDocEnumTag; +} + +export type DeclarationDiagnosticProducing = + | VariableDeclaration + | PropertyDeclaration + | PropertySignature + | BindingElement + | SetAccessorDeclaration + | GetAccessorDeclaration + | ConstructSignatureDeclaration + | CallSignatureDeclaration + | MethodDeclaration + | MethodSignature + | FunctionDeclaration + | ParameterDeclaration + | TypeParameterDeclaration + | ExpressionWithTypeArguments + | ImportEqualsDeclaration + | TypeAliasDeclaration + | ConstructorDeclaration + | IndexSignatureDeclaration + | PropertyAccessExpression + | JSDocTypedefTag + | JSDocCallbackTag + | JSDocEnumTag; + + + +/** @internal */ +export function isDeclaration(node: Node): node is NamedDeclaration { + if (node.kind === SyntaxKind.TypeParameter) { + return (node.parent && node.parent.kind !== SyntaxKind.JSDocTemplateTag) || isInJSFile(node); + } + + return isDeclarationKind(node.kind); +} + +function isDeclarationKind(kind: SyntaxKind) { + return kind === SyntaxKind.ArrowFunction + || kind === SyntaxKind.BindingElement + || kind === SyntaxKind.ClassDeclaration + || kind === SyntaxKind.ClassExpression + || kind === SyntaxKind.ClassStaticBlockDeclaration + || kind === SyntaxKind.Constructor + || kind === SyntaxKind.EnumDeclaration + || kind === SyntaxKind.EnumMember + || kind === SyntaxKind.ExportSpecifier + || kind === SyntaxKind.FunctionDeclaration + || kind === SyntaxKind.FunctionExpression + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.ImportClause + || kind === SyntaxKind.ImportEqualsDeclaration + || kind === SyntaxKind.ImportSpecifier + || kind === SyntaxKind.InterfaceDeclaration + || kind === SyntaxKind.JsxAttribute + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.MethodSignature + || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.NamespaceExportDeclaration + || kind === SyntaxKind.NamespaceImport + || kind === SyntaxKind.NamespaceExport + || kind === SyntaxKind.Parameter + || kind === SyntaxKind.PropertyAssignment + || kind === SyntaxKind.PropertyDeclaration + || kind === SyntaxKind.PropertySignature + || kind === SyntaxKind.SetAccessor + || kind === SyntaxKind.ShorthandPropertyAssignment + || kind === SyntaxKind.TypeAliasDeclaration + || kind === SyntaxKind.TypeParameter + || kind === SyntaxKind.VariableDeclaration + || kind === SyntaxKind.JSDocTypedefTag + || kind === SyntaxKind.JSDocCallbackTag + || kind === SyntaxKind.JSDocPropertyTag; +} + + +/** + * Bypasses immutability and directly sets the `parent` property of a `Node`. + * + * @internal + */ + export function setParent(child: T, parent: T["parent"] | undefined): T; + /** @internal */ + export function setParent(child: T | undefined, parent: T["parent"] | undefined): T | undefined; + /** @internal */ + export function setParent(child: T | undefined, parent: T["parent"] | undefined): T | undefined { + if (child && parent) { + (child as Mutable).parent = parent; + } + return child; + } + +/** @internal */ +export function isInJSFile(node: Node | undefined): boolean { + return !!node && !!(node.flags & NodeFlags.JavaScriptFile); +} + + +/** @internal */ +export function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration & { body: FunctionBody } | undefined { + return find(node.members, (member): member is ConstructorDeclaration & { body: FunctionBody } => isConstructorDeclaration(member) && nodeIsPresent(member.body)); +} + +// Returns true if this node is missing from the actual source code. A 'missing' node is different +// from 'undefined/defined'. When a node is undefined (which can happen for optional nodes +// in the tree), it is definitely missing. However, a node may be defined, but still be +// missing. This happens whenever the parser knows it needs to parse something, but can't +// get anything in the source code that it expects at that location. For example: +// +// let a: ; +// +// Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source +// code). So the parser will attempt to parse out a type, and will create an actual node. +// However, this node will be 'missing' in the sense that no actual source-code/tokens are +// contained within it. +/** @internal */ +export function nodeIsMissing(node: Node | undefined): boolean { + if (node === undefined) { + return true; + } + + return node.pos === node.end && node.pos >= 0 && node.kind !== SyntaxKind.EndOfFileToken; +} + +/** @internal */ +export function nodeIsPresent(node: Node | undefined): boolean { + return !nodeIsMissing(node); +} + + + +/** @internal */ +export function hasSyntacticModifier(node: Node, flags: ModifierFlags): boolean { + return !!getSelectedSyntacticModifierFlags(node, flags); +} + +/** @internal */ +export function getSelectedSyntacticModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags { + return getSyntacticModifierFlags(node) & flags; +} + +/** + * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. + * + * NOTE: This function may use `parent` pointers. + * + * @internal + */ +export function getEffectiveModifierFlags(node: Node): ModifierFlags { + return getModifierFlagsWorker(node, /*includeJSDoc*/ true); +} + +/** @internal */ +export function getEffectiveModifierFlagsAlwaysIncludeJSDoc(node: Node): ModifierFlags { + return getModifierFlagsWorker(node, /*includeJSDOc*/ true, /*alwaysIncludeJSDOc*/ true); +} + +/** + * Gets the ModifierFlags for syntactic modifiers on the provided node. The modifiers will be cached on the node to improve performance. + * + * NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. + * + * @internal + */ + export function getSyntacticModifierFlags(node: Node): ModifierFlags { + return getModifierFlagsWorker(node, /*includeJSDoc*/ false); +} + + +function getModifierFlagsWorker(node: Node, includeJSDoc: boolean, alwaysIncludeJSDoc?: boolean): ModifierFlags { + if (node.kind >= SyntaxKind.FirstToken && node.kind <= SyntaxKind.LastToken) { + return ModifierFlags.None; + } + + if (!(node.modifierFlagsCache & ModifierFlags.HasComputedFlags)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | ModifierFlags.HasComputedFlags; + } + + if (includeJSDoc && !(node.modifierFlagsCache & ModifierFlags.HasComputedJSDocModifiers) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | ModifierFlags.HasComputedJSDocModifiers; + } + + return node.modifierFlagsCache & ~(ModifierFlags.HasComputedFlags | ModifierFlags.HasComputedJSDocModifiers); +} + + +function getJSDocModifierFlagsNoCache(node: Node): ModifierFlags { + let flags = ModifierFlags.None; + if (!!node.parent && !isParameter(node)) { + if (isInJSFile(node)) { + if (getJSDocPublicTag(node)) flags |= ModifierFlags.Public; + if (getJSDocPrivateTag(node)) flags |= ModifierFlags.Private; + if (getJSDocProtectedTag(node)) flags |= ModifierFlags.Protected; + if (getJSDocReadonlyTag(node)) flags |= ModifierFlags.Readonly; + if (getJSDocOverrideTagNoCache(node)) flags |= ModifierFlags.Override; + } + if (getJSDocDeprecatedTag(node)) flags |= ModifierFlags.Deprecated; + } + + return flags; +} + +/** + * Gets the ModifierFlags for syntactic modifiers on the provided node. The modifier flags cache on the node is ignored. + * + * NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. + * + * @internal + */ + export function getSyntacticModifierFlagsNoCache(node: Node): ModifierFlags { + let flags = canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : ModifierFlags.None; + if (node.flags & NodeFlags.NestedNamespace || (node.kind === SyntaxKind.Identifier && (node as Identifier).isInJSDocNamespace)) { + flags |= ModifierFlags.Export; + } + return flags; +} + +/** @internal */ +export function modifiersToFlags(modifiers: readonly ModifierLike[] | undefined) { + let flags = ModifierFlags.None; + if (modifiers) { + for (const modifier of modifiers) { + flags |= modifierToFlag(modifier.kind); + } + } + return flags; +} + +/** @internal */ +export function modifierToFlag(token: SyntaxKind): ModifierFlags { + switch (token) { + case SyntaxKind.StaticKeyword: return ModifierFlags.Static; + case SyntaxKind.PublicKeyword: return ModifierFlags.Public; + case SyntaxKind.ProtectedKeyword: return ModifierFlags.Protected; + case SyntaxKind.PrivateKeyword: return ModifierFlags.Private; + case SyntaxKind.AbstractKeyword: return ModifierFlags.Abstract; + case SyntaxKind.AccessorKeyword: return ModifierFlags.Accessor; + case SyntaxKind.ExportKeyword: return ModifierFlags.Export; + case SyntaxKind.DeclareKeyword: return ModifierFlags.Ambient; + case SyntaxKind.ConstKeyword: return ModifierFlags.Const; + case SyntaxKind.DefaultKeyword: return ModifierFlags.Default; + case SyntaxKind.AsyncKeyword: return ModifierFlags.Async; + case SyntaxKind.ReadonlyKeyword: return ModifierFlags.Readonly; + case SyntaxKind.OverrideKeyword: return ModifierFlags.Override; + case SyntaxKind.InKeyword: return ModifierFlags.In; + case SyntaxKind.OutKeyword: return ModifierFlags.Out; + case SyntaxKind.Decorator: return ModifierFlags.Decorator; + } + return ModifierFlags.None; +} + +/** @internal */ +export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; + +/** @internal */ +export type LateVisibilityPaintedStatement = + | AnyImportSyntax + | VariableStatement + | ClassDeclaration + | FunctionDeclaration + | ModuleDeclaration + | TypeAliasDeclaration + | InterfaceDeclaration + | EnumDeclaration; + + +/** @internal */ +export function visitArray(nodes: T[] | undefined, visitor: Visitor, test: (node: Node) => node is U, start?: number, count?: number): U[] | undefined; +/** @internal */ +export function visitArray(nodes: readonly T[] | undefined, visitor: Visitor, test: (node: Node) => node is U, start?: number, count?: number): readonly U[] | undefined; +/** @internal */ +export function visitArray(nodes: T[] | undefined, visitor: Visitor, test: (node: Node) => node is T, start?: number, count?: number): T[] | undefined; +/** @internal */ +export function visitArray(nodes: readonly T[] | undefined, visitor: Visitor, test: (node: Node) => node is T, start?: number, count?: number): readonly T[] | undefined; +export function visitArray(nodes: readonly T[] | undefined, visitor: Visitor, test: (node: Node) => node is U, start?: number, count?: number) { + if (nodes === undefined) { + return nodes; + } + + // Ensure start and count have valid values + const length = nodes.length; + if (start === undefined || start < 0) { + start = 0; + } + + if (count === undefined || count > length - start) { + count = length - start; + } + + return visitArrayWorker(nodes, visitor, test, start, count) as readonly U[]; +} + + + +/** @internal */ +function visitArrayWorker(nodes: readonly T[], visitor: Visitor, test: ((node: Node) => boolean) | undefined, start: number, count: number): readonly T[] | undefined { + let updated: T[] | undefined; + + const length = nodes.length; + if (start > 0 || count < length) { + // If we are not visiting all of the original nodes, we must always create a new array. + updated = []; + } + + // Visit each original node. + for (let i = 0; i < count; i++) { + const node: T = nodes[i + start]; + const visited = node !== undefined ? visitor(node) : undefined; + if (updated !== undefined || visited === undefined || visited !== node) { + if (updated === undefined) { + // Ensure we have a copy of `nodes`, up to the current index. + updated = nodes.slice(0, i); + } + if (visited) { + if (isArray(visited)) { + for (const visitedNode of visited) { + void Debug.assertNode(visitedNode, test); + updated.push(visitedNode as T); + } + } + else { + void Debug.assertNode(visited, test); + updated.push(visited as T); + } + } + } + } + + return updated ?? nodes; +} + +/** @internal */ +export interface AllAccessorDeclarations { + firstAccessor: AccessorDeclaration; + secondAccessor: AccessorDeclaration | undefined; + getAccessor: GetAccessorDeclaration | undefined; + setAccessor: SetAccessorDeclaration | undefined; +} + +/** @internal */ +export function getThisParameter(signature: SignatureDeclaration | JSDocSignature): ParameterDeclaration | undefined { + // callback tags do not currently support this parameters + if (signature.parameters.length && !isJSDocSignature(signature)) { + const thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } +} + +/** @internal */ +export function parameterIsThisKeyword(parameter: ParameterDeclaration): boolean { + return isThisIdentifier(parameter.name); +} + +/** @internal */ +export function isThisIdentifier(node: Node | undefined): boolean { + return !!node && node.kind === SyntaxKind.Identifier && identifierIsThisKeyword(node as Identifier); +} + + +/** @internal */ +export function identifierIsThisKeyword(id: Identifier): boolean { + return id.originalKeywordKind === SyntaxKind.ThisKeyword; +} + + +/** @internal */ +export function positionIsSynthesized(pos: number): boolean { + // This is a fast way of testing the following conditions: + // pos === undefined || pos === null || isNaN(pos) || pos < 0; + return !(pos >= 0); +} + +/** @internal */ +export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean, stopAtComments?: boolean, inJSDoc?: boolean): number { + if (positionIsSynthesized(pos)) { + return pos; + } + + let canConsumeStar = false; + // Keep in sync with couldStartTrivia + while (true) { + const ch = text.charCodeAt(pos); + switch (ch) { + case CharacterCodes.carriageReturn: + if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) { + pos++; + } + // falls through + case CharacterCodes.lineFeed: + pos++; + if (stopAfterLineBreak) { + return pos; + } + canConsumeStar = !!inJSDoc; + continue; + case CharacterCodes.tab: + case CharacterCodes.verticalTab: + case CharacterCodes.formFeed: + case CharacterCodes.space: + pos++; + continue; + case CharacterCodes.slash: + if (stopAtComments) { + break; + } + if (text.charCodeAt(pos + 1) === CharacterCodes.slash) { + pos += 2; + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + canConsumeStar = false; + continue; + } + if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) { + pos += 2; + while (pos < text.length) { + if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) { + pos += 2; + break; + } + pos++; + } + canConsumeStar = false; + continue; + } + break; + + case CharacterCodes.lessThan: + case CharacterCodes.bar: + case CharacterCodes.equals: + case CharacterCodes.greaterThan: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + canConsumeStar = false; + continue; + } + break; + + case CharacterCodes.hash: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + canConsumeStar = false; + continue; + } + break; + + case CharacterCodes.asterisk: + if (canConsumeStar) { + pos++; + canConsumeStar = false; + continue; + } + break; + + default: + if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpaceLike(ch))) { + pos++; + continue; + } + break; + } + return pos; + } +} +// All conflict markers consist of the same character repeated seven times. If it is +// a <<<<<<< or >>>>>>> marker then it is also followed by a space. +const mergeConflictMarkerLength = "<<<<<<<".length; + +function isConflictMarkerTrivia(text: string, pos: number) { + Debug.assert(pos >= 0); + + // Conflict markers must be at the start of a line. + if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { + const ch = text.charCodeAt(pos); + + if ((pos + mergeConflictMarkerLength) < text.length) { + for (let i = 0; i < mergeConflictMarkerLength; i++) { + if (text.charCodeAt(pos + i) !== ch) { + return false; + } + } + + return ch === CharacterCodes.equals || + text.charCodeAt(pos + mergeConflictMarkerLength) === CharacterCodes.space; + } + } + + return false; +} + +function scanConflictMarkerTrivia(text: string, pos: number, error?: (diag: DiagnosticMessage, pos?: number, len?: number) => void) { + if (error) { + error(Diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength); + } + + const ch = text.charCodeAt(pos); + const len = text.length; + + if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) { + while (pos < len && !isLineBreak(text.charCodeAt(pos))) { + pos++; + } + } + else { + Debug.assert(ch === CharacterCodes.bar || ch === CharacterCodes.equals); + // Consume everything from the start of a ||||||| or ======= marker to the start + // of the next ======= or >>>>>>> marker. + while (pos < len) { + const currentChar = text.charCodeAt(pos); + if ((currentChar === CharacterCodes.equals || currentChar === CharacterCodes.greaterThan) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + break; + } + + pos++; + } + } + + return pos; +} + +const shebangTriviaRegex = /^#!.*/; + +/** @internal */ +export function isShebangTrivia(text: string, pos: number) { + // Shebangs check must only be done at the start of the file + Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); +} + +/** @internal */ +export function scanShebangTrivia(text: string, pos: number) { + const shebang = shebangTriviaRegex.exec(text)![0]; + pos = pos + shebang.length; + return pos; +} + + +/** @internal */ +export function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile) { + return node.kind !== SyntaxKind.JsxText ? getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; +} + +export function isNightly() { + return false; +} + +export function createGetSymbolAccessibilityDiagnosticForNode(node: DeclarationDiagnosticProducing): GetSymbolAccessibilityDiagnostic { + return () => { + debugger; + throw new Error(); + }; +} + +/** @internal */ +export function getOriginalNodeId(node: Node) { + node = getOriginalNode(node); + return node ? getNodeId(node) : 0; +} + +export function getOriginalNode(node: Node): Node; +export function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; +export function getOriginalNode(node: Node | undefined): Node | undefined; +export function getOriginalNode(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined; +export function getOriginalNode(node: Node | undefined, nodeTest?: (node: Node | undefined) => boolean): Node | undefined { + if (node) { + while ((node as any).original !== undefined) { + node = (node as any).original; + } + } + + return !nodeTest || nodeTest(node) ? node : undefined; +} + +let nextNodeId = 0; +/** @internal */ +export function getNodeId(node: Node): number +export function getNodeId(node: any): number { + if (!node.id) { + nextNodeId++; + node.id = nextNodeId; + } + return node.id; +} + + +/** @internal */ +export function isExternalOrCommonJsModule(file: SourceFile): boolean { + return ((file as any).externalModuleIndicator || (file as any).commonJsModuleIndicator) !== undefined; +} + + +/** @internal */ +export function isJsonSourceFile(file: SourceFile): file is JsonSourceFile { + return (file as any).scriptKind === ScriptKind.JSON; +} + + +/** @internal */ +export function isSourceFileNotJson(file: SourceFile) { + return !isJsonSourceFile(file); +} + +/** @internal */ +export function isSourceFileJS(file: SourceFile): boolean { + return isInJSFile(file); +} + +/** @internal */ +export function getResolvedExternalModuleName(host: ResolveModuleNameResolutionHost, file: SourceFile, referenceFile?: SourceFile): string { + if(!file.moduleName) { + throw new Error("Not implemented"); + } + return file.moduleName; +} + + +/** @internal */ +export function isAnyImportSyntax(node: Node): node is AnyImportSyntax { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + return true; + default: + return false; + } +} + +/** @internal */ +export function createEmptyExports(factory: NodeFactory) { + return factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([]), /*moduleSpecifier*/ undefined); +} + + +/** @internal */ +export function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean { + return !!(module.flags & NodeFlags.GlobalAugmentation); +} + +/** @internal */ +export function isExternalModuleAugmentation(node: Node): node is AmbientModuleDeclaration { + return isAmbientModule(node) && isModuleAugmentationExternal(node); +} + + +/** @internal */ +export function isModuleAugmentationExternal(node: AmbientModuleDeclaration) { + // external module augmentation is a ambient module declaration that is either: + // - defined in the top level scope and source file is an external module + // - defined inside ambient module declaration located in the top level scope and source file not an external module + switch (node.parent.kind) { + case SyntaxKind.SourceFile: + return isExternalModule(node.parent); + case SyntaxKind.ModuleBlock: + return isAmbientModule(node.parent.parent) && isSourceFile(node.parent.parent.parent) && !isExternalModule(node.parent.parent.parent); + } + return false; +} + +// See also `isExternalOrCommonJsModule` in utilities.ts +export function isExternalModule(file: SourceFile): boolean { + return (file as any).externalModuleIndicator !== undefined; +} + +/** @internal */ +export function isAmbientModule(node: Node): node is AmbientModuleDeclaration { + return isModuleDeclaration(node) && (node.name.kind === SyntaxKind.StringLiteral || isGlobalScopeAugmentation(node)); +} + + +/** @internal */ +export function hasEffectiveModifiers(node: Node) { + return getEffectiveModifierFlags(node) !== ModifierFlags.None; +} + +/** @internal */ +export function hasSyntacticModifiers(node: Node) { + return getSyntacticModifierFlags(node) !== ModifierFlags.None; +} + +/** @internal */ +export function hasEffectiveModifier(node: Node, flags: ModifierFlags): boolean { + return !!getSelectedEffectiveModifierFlags(node, flags); +} + +/** @internal */ +export function getSelectedEffectiveModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags { + return getEffectiveModifierFlags(node) & flags; +} + + +/** + * A declaration has a dynamic name if all of the following are true: + * 1. The declaration has a computed property name. + * 2. The computed name is *not* expressed as a StringLiteral. + * 3. The computed name is *not* expressed as a NumericLiteral. + * 4. The computed name is *not* expressed as a PlusToken or MinusToken + * immediately followed by a NumericLiteral. + * + * @internal + */ + export function hasDynamicName(declaration: Declaration): declaration is DynamicNamedDeclaration | DynamicNamedBinaryExpression { + const name = getNameOfDeclaration(declaration); + return !!name && isDynamicName(name); +} + +/** @internal */ +export function isDynamicName(name: DeclarationName): boolean { + if (!(name.kind === SyntaxKind.ComputedPropertyName || name.kind === SyntaxKind.ElementAccessExpression)) { + return false; + } + const expr = isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr); +} + +/** @internal */ +export function isSignedNumericLiteral(node: Node): node is PrefixUnaryExpression & { operand: NumericLiteral } { + return isPrefixUnaryExpression(node) && (node.operator === SyntaxKind.PlusToken || node.operator === SyntaxKind.MinusToken) && isNumericLiteral(node.operand); +} + +/** @internal */ +export function isLateVisibilityPaintedStatement(node: Node): node is LateVisibilityPaintedStatement { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.VariableStatement: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.EnumDeclaration: + return true; + default: + return false; + } +} + + +/** @internal */ +export function isBindingPattern(node: Node | undefined): node is BindingPattern { + if (node) { + const kind = node.kind; + return kind === SyntaxKind.ArrayBindingPattern + || kind === SyntaxKind.ObjectBindingPattern; + } + + return false; +} + + +/** @internal */ +export function isLiteralImportTypeNode(n: Node): n is LiteralImportTypeNode { + return isImportTypeNode(n) && isLiteralTypeNode(n.argument) && isStringLiteral(n.argument.literal); +} + + +export function isImportTypeNode(node: Node): node is ImportTypeNode { + return node.kind === SyntaxKind.ImportType; +} + + +/** @internal */ +export function skipParentheses(node: Expression, excludeJSDocTypeAssertions?: boolean): Expression; +/** @internal */ +export function skipParentheses(node: Node, excludeJSDocTypeAssertions?: boolean): Node; +/** @internal */ +export function skipParentheses(node: Node, excludeJSDocTypeAssertions?: boolean): Node { + const flags = excludeJSDocTypeAssertions ? + OuterExpressionKinds.Parentheses | OuterExpressionKinds.ExcludeJSDocTypeAssertion : + OuterExpressionKinds.Parentheses; + return skipOuterExpressions(node, flags); +} + + +/** @internal */ +export function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression; +/** @internal */ +export function skipOuterExpressions(node: Node, kinds?: OuterExpressionKinds): Node; +/** @internal */ +export function skipOuterExpressions(node: Node, kinds = OuterExpressionKinds.All) { + while (isOuterExpression(node, kinds)) { + node = node.expression; + } + return node; +} + +/** @internal */ +export function isLiteralComputedPropertyDeclarationName(node: Node) { + return isStringOrNumericLiteralLike(node) && + node.parent.kind === SyntaxKind.ComputedPropertyName && + isDeclaration(node.parent.parent); +} + + +/** @internal */ +export function isStringOrNumericLiteralLike(node: Node): node is StringLiteralLike | NumericLiteral { + return isStringLiteralLike(node) || isNumericLiteral(node); +} + + +/** @internal */ +export function isOuterExpression(node: Node, kinds = OuterExpressionKinds.All): node is OuterExpression { + switch (node.kind) { + case SyntaxKind.ParenthesizedExpression: + if (kinds & OuterExpressionKinds.ExcludeJSDocTypeAssertion && isJSDocTypeAssertion(node)) { + return false; + } + return (kinds & OuterExpressionKinds.Parentheses) !== 0; + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: + case SyntaxKind.SatisfiesExpression: + return (kinds & OuterExpressionKinds.TypeAssertions) !== 0; + case SyntaxKind.NonNullExpression: + return (kinds & OuterExpressionKinds.NonNullAssertions) !== 0; + case SyntaxKind.PartiallyEmittedExpression: + return (kinds & OuterExpressionKinds.PartiallyEmittedExpressions) !== 0; + } + return false; +} + +/** @internal */ +export function isJSDocTypeAssertion(node: Node): node is JSDocTypeAssertion { + return isParenthesizedExpression(node) + && isInJSFile(node) + && !!getJSDocTypeTag(node); +} + + +/** + * Sets `EmitFlags.NoComments` on a node and removes any leading and trailing synthetic comments. + * @internal + */ + export function removeAllComments(node: T): T { + const emitNode = getOrCreateEmitNode(node); + emitNode.flags |= EmitFlags.NoComments; + emitNode.leadingComments = undefined; + emitNode.trailingComments = undefined; + return node; +} + + +/** + * Associates a node with the current transformation, initializing + * various transient transformation properties. + * @internal + */ + export function getOrCreateEmitNode(node: Node): EmitNode { + if (!node.emitNode) { + if (isParseTreeNode(node)) { + // To avoid holding onto transformation artifacts, we keep track of any + // parse tree node we are annotating. This allows us to clean them up after + // all transformations have completed. + if (node.kind === SyntaxKind.SourceFile) { + return node.emitNode = { annotatedNodes: [node] } as EmitNode; + } + + const sourceFile = getSourceFileOfNode(getParseTreeNode(getSourceFileOfNode(node))) ?? Debug.fail("Could not determine parsed source file."); + getOrCreateEmitNode(sourceFile).annotatedNodes!.push(node); + } + + node.emitNode = {} as EmitNode; + } + else { + Debug.assert(!(node.emitNode.flags & (EmitFlags as any).Immutable), "Invalid attempt to mutate an immutable node."); + } + return node.emitNode; +} + +/** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @returns The original parse tree node if found; otherwise, undefined. + */ + export function getParseTreeNode(node: Node | undefined): Node | undefined; + + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. + * @returns The original parse tree node if found; otherwise, undefined. + */ + export function getParseTreeNode(node: T | undefined, nodeTest?: (node: Node) => node is T): T | undefined; + export function getParseTreeNode(node: Node | undefined, nodeTest?: (node: Node) => boolean): Node | undefined { + if (node === undefined || isParseTreeNode(node)) { + return node; + } + + node = node.original; + while (node) { + if (isParseTreeNode(node)) { + return !nodeTest || nodeTest(node) ? node : undefined; + } + node = node.original; + } + } + + +/** @internal */ +export function needsScopeMarker(result: Statement) { + return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasSyntacticModifier(result, ModifierFlags.Export) && !isAmbientModule(result); +} + + +/** @internal */ +export function isAnyImportOrReExport(node: Node): node is AnyImportOrReExport { + return isAnyImportSyntax(node) || isExportDeclaration(node); +} + +/** + * True if has jsdoc nodes attached to it. + * + * @internal + */ +// TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times +export function hasJSDocNodes(node: Node): node is HasJSDoc & { jsDoc?: JSDoc[] } { + const { jsDoc } = node as { jsDoc?: JSDoc[] }; + return !!jsDoc && jsDoc.length > 0; +} + +/** @internal */ +export function isExternalModuleIndicator(result: Statement) { + // Exported top-level member indicates moduleness + return isAnyImportOrReExport(result) || isExportAssignment(result) || hasSyntacticModifier(result, ModifierFlags.Export); +} + + + +/** @internal */ +export function getOutputPathsFor(sourceFile: SourceFile | Bundle, host: EmitHost, forceDtsPaths: boolean): EmitFileNames { + const options = host.getCompilerOptions(); + if (sourceFile.kind === SyntaxKind.Bundle) { + return getOutputPathsForBundle(options, forceDtsPaths); + } + else { + const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile.fileName, options)); + const isJsonFile = isJsonSourceFile(sourceFile); + // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it + const isJsonEmittedToSameLocation = isJsonFile && + comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames?.()) === Comparison.EqualTo; + const jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; + const sourceMapFilePath = !jsFilePath || isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); + const declarationFilePath = (forceDtsPaths || (getEmitDeclarations(options) && !isJsonFile)) ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; + return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath: undefined }; + } +} + + +/** @internal */ +export function getDeclarationEmitOutputFilePath(fileName: string, host: EmitHost) { + return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), f => host.getCanonicalFileName(f)); +} + +/** @internal */ +export function getDeclarationEmitOutputFilePathWorker(fileName: string, options: CompilerOptions, currentDirectory: string, commonSourceDirectory: string, getCanonicalFileName: GetCanonicalFileName): string { + const outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified + + const path = outputDir + ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName) + : fileName; + const declarationExtension = getDeclarationEmitExtensionForPath(path); + return removeFileExtension(path) + declarationExtension; +} + +/** @internal */ +export function getDeclarationEmitExtensionForPath(path: string) { + return fileExtensionIsOneOf(path, [Extension.Mjs, Extension.Mts]) ? Extension.Dmts : + fileExtensionIsOneOf(path, [Extension.Cjs, Extension.Cts]) ? Extension.Dcts : + fileExtensionIsOneOf(path, [Extension.Json]) ? `.json.d.ts` : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + Extension.Dts; +} + + +/** @internal */ +export function getOutputExtension(fileName: string, options: CompilerOptions): Extension { + return fileExtensionIs(fileName, Extension.Json) ? Extension.Json : + options.jsx === JsxEmit.Preserve && fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx]) ? Extension.Jsx : + fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs]) ? Extension.Mjs : + fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs]) ? Extension.Cjs : + Extension.Js; +} + + +/** @internal */ +export function getOwnEmitOutputFilePath(fileName: string, host: EmitHost, extension: string) { + const compilerOptions = host.getCompilerOptions(); + let emitOutputFilePathWithoutExtension: string; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(fileName, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = removeFileExtension(fileName); + } + + return emitOutputFilePathWithoutExtension + extension; +} + +/** @internal */ +export function getSourceFilePathInNewDir(fileName: string, host: EmitHost, newDirPath: string): string { + return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), f => host.getCanonicalFileName(f)); +} + + +/** @internal */ +export function getSourceFilePathInNewDirWorker(fileName: string, newDirPath: string, currentDirectory: string, commonSourceDirectory: string, getCanonicalFileName: GetCanonicalFileName): string { + let sourceFilePath = getNormalizedAbsolutePath(fileName, currentDirectory); + const isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0; + sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; + return combinePaths(newDirPath, sourceFilePath); +} + + + +/** @internal */ +export function getOutputPathsForBundle(options: CompilerOptions, forceDtsPaths: boolean): EmitFileNames { + const outPath = outFile(options)!; + const jsFilePath = options.emitDeclarationOnly ? undefined : outPath; + const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); + const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? removeFileExtension(outPath) + Extension.Dts : undefined; + const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; + const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); + return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath }; +} + + +/** @internal */ +export function outFile(options: CompilerOptions) { + return options.outFile || options.out; +} + + +function getSourceMapFilePath(jsFilePath: string, options: CompilerOptions) { + return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; +} +/** @internal */ +export function getEmitDeclarations(compilerOptions: CompilerOptions): boolean { + return !!(compilerOptions.declaration || compilerOptions.composite); +} + + +/** @internal */ +export function getAreDeclarationMapsEnabled(options: CompilerOptions) { + return !!(getEmitDeclarations(options) && options.declarationMap); +} + + +/** @internal */ +export function getSetAccessorValueParameter(accessor: SetAccessorDeclaration): ParameterDeclaration | undefined { + if (accessor && accessor.parameters.length > 0) { + const hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); + return accessor.parameters[hasThis ? 1 : 0]; + } +} + + +function getCanonicalAbsolutePath(host: ResolveModuleNameResolutionHost, path: string) { + return host.getCanonicalFileName(getNormalizedAbsolutePath(path, host.getCurrentDirectory())); +} + + +/** @internal */ +export function getExternalModuleNameFromDeclaration(host: ResolveModuleNameResolutionHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): string | undefined { + const file = resolver.getExternalModuleFileFromDeclaration(declaration); + if (!file || file.isDeclarationFile) { + return undefined; + } + // If the declaration already uses a non-relative name, and is outside the common source directory, continue to use it + const specifier = getExternalModuleName(declaration); + if (specifier && isStringLiteralLike(specifier) && !pathIsRelative(specifier.text) && + getCanonicalAbsolutePath(host, file.path).indexOf(getCanonicalAbsolutePath(host, ensureTrailingDirectorySeparator(host.getCommonSourceDirectory()))) === -1) { + return undefined; + } + return getResolvedExternalModuleName(host, file); +} + + +/** @internal */ +export function getExternalModuleName(node: AnyImportOrReExport | ImportTypeNode | ImportCall | ModuleDeclaration): Expression | undefined { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ExportDeclaration: + return node.moduleSpecifier; + case SyntaxKind.ImportEqualsDeclaration: + return node.moduleReference.kind === SyntaxKind.ExternalModuleReference ? node.moduleReference.expression : undefined; + case SyntaxKind.ImportType: + return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; + case SyntaxKind.CallExpression: + return node.arguments[0]; + case SyntaxKind.ModuleDeclaration: + return node.name.kind === SyntaxKind.StringLiteral ? node.name : undefined; + default: + return Debug.assertNever(node); + } +} + + +/** @internal */ +export function getExternalModuleImportEqualsDeclarationExpression(node: Node) { + Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return ((node as ImportEqualsDeclaration).moduleReference as ExternalModuleReference).expression; +} + +/** @internal */ +export function isExternalModuleImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration & { moduleReference: ExternalModuleReference } { + return node.kind === SyntaxKind.ImportEqualsDeclaration && (node as ImportEqualsDeclaration).moduleReference.kind === SyntaxKind.ExternalModuleReference; +} + + +/** @internal */ +export function getResolutionModeOverrideForClause(clause: AssertClause | undefined, grammarErrorOnNode?: (node: Node, diagnostic: DiagnosticMessage) => void) { + if (!clause) return undefined; + if (length(clause.elements) !== 1) { + grammarErrorOnNode?.(clause, Diagnostics.Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require); + return undefined; + } + const elem = clause.elements[0]; + if (!isStringLiteralLike(elem.name)) return undefined; + if (elem.name.text !== "resolution-mode") { + grammarErrorOnNode?.(elem.name, Diagnostics.resolution_mode_is_the_only_valid_key_for_type_import_assertions); + return undefined; + } + if (!isStringLiteralLike(elem.value)) return undefined; + if (elem.value.text !== "import" && elem.value.text !== "require") { + grammarErrorOnNode?.(elem.value, Diagnostics.resolution_mode_should_be_either_require_or_import); + return undefined; + } + return elem.value.text === "import" ? ModuleKind.ESNext : ModuleKind.CommonJS; +} + + +/** @internal */ +export function isEntityNameExpression(node: Node): node is EntityNameExpression { + return node.kind === SyntaxKind.Identifier || isPropertyAccessEntityNameExpression(node); +} + + +/** @internal */ +export function isPropertyAccessEntityNameExpression(node: Node): node is PropertyAccessEntityNameExpression { + return isPropertyAccessExpression(node) && isIdentifier(node.name) && isEntityNameExpression(node.expression); +} + + +/** @internal */ +export function getEffectiveBaseTypeNode(node: ClassLikeDeclaration | InterfaceDeclaration) { + const baseType = getClassExtendsHeritageElement(node); + if (baseType && isInJSFile(node)) { + // Prefer an @augments tag because it may have type parameters. + const tag = getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return baseType; +} + + +/** @internal */ +export function getClassExtendsHeritageElement(node: ClassLikeDeclaration | InterfaceDeclaration) { + const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; +} + + +/** @internal */ +export function getHeritageClause(clauses: NodeArray | undefined, kind: SyntaxKind) { + if (clauses) { + for (const clause of clauses) { + if (clause.token === kind) { + return clause; + } + } + } + + return undefined; +} + + +/** + * Gets flags that control emit behavior of a node. + * + * @internal + */ + export function getEmitFlags(node: Node): EmitFlags { + const emitNode = node.emitNode; + return emitNode && emitNode.flags || 0; +} + + +/** @internal */ +export function getEmitModuleResolutionKind(compilerOptions: CompilerOptions) { + let moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + switch (getEmitModuleKind(compilerOptions)) { + case ModuleKind.CommonJS: + moduleResolution = ModuleResolutionKind.NodeJs; + break; + case ModuleKind.Node16: + moduleResolution = ModuleResolutionKind.Node16; + break; + case ModuleKind.NodeNext: + moduleResolution = ModuleResolutionKind.NodeNext; + break; + default: + moduleResolution = ModuleResolutionKind.Classic; + break; + } + } + return moduleResolution; +} +/** @internal */ +export function getEmitModuleKind(compilerOptions: {module?: CompilerOptions["module"], target?: CompilerOptions["target"]}) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS; +} + + +/** @internal */ +export function getEmitScriptTarget(compilerOptions: {module?: CompilerOptions["module"], target?: CompilerOptions["target"]}) { + return compilerOptions.target || + (compilerOptions.module === ModuleKind.Node16 && ScriptTarget.ES2022) || + (compilerOptions.module === ModuleKind.NodeNext && ScriptTarget.ESNext) || + ScriptTarget.ES3; +} + + +/** @internal */ +export function removePrefix(str: string, prefix: string): string { + return startsWith(str, prefix) ? str.substr(prefix.length) : str; +} + +/** @internal */ +export function tryRemovePrefix(str: string, prefix: string, getCanonicalFileName: GetCanonicalFileName = identity): string | undefined { + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; +} + +const extensionsToRemove = [Extension.Dts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Mts, Extension.Cjs, Extension.Cts, Extension.Ts, Extension.Js, Extension.Tsx, Extension.Jsx, Extension.Json]; + +/** @internal */ +export function isAnySupportedFileExtension(path: string): boolean { + return tryGetExtensionFromPath(path) !== undefined; +} + +/** @internal */ +export function tryGetExtensionFromPath(path: string): Extension | undefined { + return find(extensionsToRemove, e => fileExtensionIs(path, e)); +} + + + +/** @internal */ +export interface NodeModulePathParts { + readonly topLevelNodeModulesIndex: number; + readonly topLevelPackageNameIndex: number; + readonly packageRootIndex: number; + readonly fileNameIndex: number; +} +/** @internal */ +export function getNodeModulePathParts(fullPath: string): NodeModulePathParts | undefined { + // If fullPath can't be valid module file within node_modules, returns undefined. + // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js + // Returns indices: ^ ^ ^ ^ + + let topLevelNodeModulesIndex = 0; + let topLevelPackageNameIndex = 0; + let packageRootIndex = 0; + let fileNameIndex = 0; + + const enum States { + BeforeNodeModules, + NodeModules, + Scope, + PackageContent + } + + let partStart = 0; + let partEnd = 0; + let state = States.BeforeNodeModules; + + while (partEnd >= 0) { + partStart = partEnd; + partEnd = fullPath.indexOf("/", partStart + 1); + switch (state) { + case States.BeforeNodeModules: + if (fullPath.indexOf(nodeModulesPathPart, partStart) === partStart) { + topLevelNodeModulesIndex = partStart; + topLevelPackageNameIndex = partEnd; + state = States.NodeModules; + } + break; + case States.NodeModules: + case States.Scope: + if (state === States.NodeModules && fullPath.charAt(partStart + 1) === "@") { + state = States.Scope; + } + else { + packageRootIndex = partEnd; + state = States.PackageContent; + } + break; + case States.PackageContent: + if (fullPath.indexOf(nodeModulesPathPart, partStart) === partStart) { + state = States.NodeModules; + } + else { + state = States.PackageContent; + } + break; + } + } + + fileNameIndex = partStart; + + return state > States.NodeModules ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : undefined; +} + + +/** @internal */ +export const nodeModulesPathPart = "/node_modules/"; +/** @internal */ +export function pathContainsNodeModules(path: string): boolean { + return stringContains(path, nodeModulesPathPart); +} + + + +/** + * Gets the extension from a path. + * Path must have a valid extension. + * + * @internal + */ + export function extensionFromPath(path: string): Extension { + const ext = tryGetExtensionFromPath(path); + return ext !== undefined ? ext : Debug.fail(`File ${path} has unknown extension.`); +} + +const allSupportedExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Js, Extension.Jsx], [Extension.Cts, Extension.Dcts, Extension.Cjs], [Extension.Mts, Extension.Dmts, Extension.Mjs]]; +const allSupportedExtensionsWithJson: readonly Extension[][] = [...allSupportedExtensions, [Extension.Json]]; + +/** @internal */ +export function getSupportedExtensions(options?: CompilerOptions): readonly Extension[][]; +/** @internal */ +export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[][]; +/** @internal */ +export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[][] { + const needJsExtensions = options && getAllowJSCompilerOption(options); + + if (!extraFileExtensions || extraFileExtensions.length === 0) { + return needJsExtensions ? allSupportedExtensions : supportedTSExtensions; + } + + const builtins = needJsExtensions ? allSupportedExtensions : supportedTSExtensions; + const flatBuiltins = flatten(builtins); + const extensions = [ + ...builtins, + ...mapDefined(extraFileExtensions, x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension as Extension) === -1 ? [x.extension] : undefined) + ]; + + return extensions; +} +/** @internal */ +export const supportedJSExtensions: readonly Extension[][] = [[Extension.Js, Extension.Jsx], [Extension.Mjs], [Extension.Cjs]]; +/** @internal */ +export const supportedJSExtensionsFlat: readonly Extension[] = flatten(supportedJSExtensions); +/** + * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) + * + * @internal + */ + export const supportedTSExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts], [Extension.Cts, Extension.Dcts], [Extension.Mts, Extension.Dmts]]; + /** @internal */ + export const supportedTSExtensionsFlat: readonly Extension[] = flatten(supportedTSExtensions); + +/** @internal */ +export function hasJSFileExtension(fileName: string): boolean { + return some(supportedJSExtensionsFlat, extension => fileExtensionIs(fileName, extension)); +} + +/** @internal */ +export function hasTSFileExtension(fileName: string): boolean { + return some(supportedTSExtensionsFlat, extension => fileExtensionIs(fileName, extension)); +} + +/** @internal */ +export function getAllowJSCompilerOption(compilerOptions: CompilerOptions): boolean { + return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs; +} + +function isJSLike(scriptKind: ScriptKind | undefined): boolean { + return scriptKind === ScriptKind.JS || scriptKind === ScriptKind.JSX; +} + +export function getFirstIdentifier(node: EntityNameOrEntityNameExpression): Identifier { + switch (node.kind) { + case SyntaxKind.Identifier: + return node; + case SyntaxKind.QualifiedName: + do { + node = node.left; + } while (node.kind !== SyntaxKind.Identifier); + return node; + case SyntaxKind.PropertyAccessExpression: + do { + node = node.expression; + } while (node.kind !== SyntaxKind.Identifier); + return node; + } +} + + +/** @internal */ +export function isPartOfTypeNode(node: Node): boolean { + if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) { + return true; + } + + switch (node.kind) { + case SyntaxKind.AnyKeyword: + case SyntaxKind.UnknownKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.BigIntKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.SymbolKeyword: + case SyntaxKind.ObjectKeyword: + case SyntaxKind.UndefinedKeyword: + case SyntaxKind.NeverKeyword: + return true; + case SyntaxKind.VoidKeyword: + return node.parent.kind !== SyntaxKind.VoidExpression; + case SyntaxKind.ExpressionWithTypeArguments: + return isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case SyntaxKind.TypeParameter: + return node.parent.kind === SyntaxKind.MappedType || node.parent.kind === SyntaxKind.InferType; + + // Identifiers and qualified names may be type nodes, depending on their context. Climb + // above them to find the lowest container + case SyntaxKind.Identifier: + // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. + if (node.parent.kind === SyntaxKind.QualifiedName && (node.parent as QualifiedName).right === node) { + node = node.parent; + } + else if (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent as PropertyAccessExpression).name === node) { + node = node.parent; + } + // At this point, node is either a qualified name or an identifier + Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression, + "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + // falls through + + case SyntaxKind.QualifiedName: + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ThisKeyword: { + const { parent } = node; + if (parent.kind === SyntaxKind.TypeQuery) { + return false; + } + if (parent.kind === SyntaxKind.ImportType) { + return !(parent as ImportTypeNode).isTypeOf; + } + // Do not recursively call isPartOfTypeNode on the parent. In the example: + // + // let a: A.B.C; + // + // Calling isPartOfTypeNode would consider the qualified name A.B a type node. + // Only C and A.B.C are type nodes. + if (SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= SyntaxKind.LastTypeNode) { + return true; + } + switch (parent.kind) { + case SyntaxKind.ExpressionWithTypeArguments: + return isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + case SyntaxKind.TypeParameter: + return node === (parent as TypeParameterDeclaration).constraint; + case SyntaxKind.JSDocTemplateTag: + return node === (parent as JSDocTemplateTag).constraint; + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.Parameter: + case SyntaxKind.VariableDeclaration: + return node === (parent as HasType).type; + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + case SyntaxKind.Constructor: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return node === (parent as FunctionLikeDeclaration).type; + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: + return node === (parent as SignatureDeclaration).type; + case SyntaxKind.TypeAssertionExpression: + return node === (parent as TypeAssertion).type; + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + return contains((parent as CallExpression).typeArguments, node); + case SyntaxKind.TaggedTemplateExpression: + // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. + return false; + } + } + } + + return false; +} +/** @internal */ +export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): node is ExpressionWithTypeArguments { + return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; +} +export function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined { + const cls = tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node); + return cls && !cls.isImplements ? cls.class : undefined; +} + +/** @internal */ +export interface ClassImplementingOrExtendingExpressionWithTypeArguments { + readonly class: ClassLikeDeclaration; + readonly isImplements: boolean; +} +/** @internal */ +export function tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node: Node): ClassImplementingOrExtendingExpressionWithTypeArguments | undefined { + return isExpressionWithTypeArguments(node) + && isHeritageClause(node.parent) + && isClassLike(node.parent.parent) + ? { class: node.parent.parent, isImplements: node.parent.token === SyntaxKind.ImplementsKeyword } + : undefined; +} +export function isClassLike(node: Node): node is ClassLikeDeclaration { + return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression); +} + +export const supportedDeclarationExtensions: readonly Extension[] = [Extension.Dts, Extension.Dcts, Extension.Dmts]; +/** @internal */ +export function isDeclarationFileName(fileName: string): boolean { + return fileExtensionIsOneOf(fileName, supportedDeclarationExtensions); +} + + + +/** @internal */ +export function cloneCompilerOptions(options: CompilerOptions): CompilerOptions { + const result = clone(options); + setConfigFileInOptions(result, options && options.configFile as any); + return result; +} +/** @internal */ +export function setConfigFileInOptions(options: CompilerOptions, configFile: TsConfigSourceFile | undefined) { + if (configFile) { + Object.defineProperty(options, "configFile", { enumerable: false, writable: false, value: configFile }); + } +} + +const carriageReturnLineFeed = "\r\n"; +const lineFeed = "\n"; +/** @internal */ +export function getNewLineCharacter(options: CompilerOptions | PrinterOptions, getNewLine?: () => string): string { + switch (options.newLine) { + case NewLineKind.CarriageReturnLineFeed: + return carriageReturnLineFeed; + case NewLineKind.LineFeed: + return lineFeed; + } + return getNewLine ? getNewLine() : sys ? sys.newLine : carriageReturnLineFeed; +} + + +export function isAmbientDeclaration(node: Node) { + // @ts-expect-error NodeFlags.Ambient is not exposed + return node.flags & NodeFlags.Ambient +} + +export function isEnumConst(node: EnumDeclaration): boolean { + return !!(getSyntacticModifierFlags(node) & ModifierFlags.Const); +} + + +function idText(id: Identifier) { return id.escapedText; } +/** @internal */ +export function nodeHasName(statement: Node, name: Identifier) { + if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name as Identifier) === idText(name)) { + return true; + } + if (isVariableStatement(statement) && some(statement.declarationList.declarations, d => nodeHasName(d, name))) { + return true; + } + return false; +} + +/** @internal */ +export function isNamedDeclaration(node: Node): node is NamedDeclaration & { name: DeclarationName } { + return !!(node as NamedDeclaration).name; // A 'name' property should always be a DeclarationName. +} + +/** + * @internal + */ +export function hasIdentifierComputedName(declaration: Declaration): declaration is DynamicNamedDeclaration | DynamicNamedBinaryExpression { + const name = getNameOfDeclaration(declaration); + return !!name && isIdentifierComputedName(name); +} +/** @internal */ +export function isIdentifierComputedName(name: DeclarationName): boolean { + if (!(name.kind === SyntaxKind.ComputedPropertyName || name.kind === SyntaxKind.ElementAccessExpression)) { + return false; + } + let expr = isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; + while(isPropertyAccessExpression(expr)) { + expr = expr.expression; + } + return isIdentifier(expr); +} + +/** @internal */ +export function isIdentifierANonContextualKeyword(node: Identifier): boolean { + const originalKeywordKind = identifierToKeywordKind(node); + return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); +} + +/** @internal */ +export function isContextualKeyword(token: SyntaxKind): boolean { + return SyntaxKind.AbstractKeyword <= token && token <= SyntaxKind.OfKeyword; +} \ No newline at end of file diff --git a/external-declarations/src/main.ts b/external-declarations/src/main.ts new file mode 100644 index 0000000000000..4b4a709094a31 --- /dev/null +++ b/external-declarations/src/main.ts @@ -0,0 +1,113 @@ +import * as ts from 'typescript' +import * as fsp from 'fs/promises' +import * as fs from 'fs' +import * as path from 'path' +import { transformFile } from './compiler/transform-file'; +import { ArgType, parseArgs } from './utils/cli-parser'; +import { ensureDir, readAllFiles } from './utils/fs-utils'; +import { changeAnyExtension, normalizePath } from './compiler/path-utils'; + + +(ts as any).Debug.enableDebugInfo(); + + +const { value: parsedArgs, printUsageOnErrors } = parseArgs(process.argv.slice(2), { + default: ArgType.StringArray(), + project: { + type: ArgType.String(), + description: "Project configuration", + required: true + }, + watch: { + type: ArgType.Boolean(), + description: "Keep watching", + }, + declarationDir: { + type: ArgType.String(), + description: "Keep watching", + } +}); +printUsageOnErrors(); + +let projectConfig = normalizePath(path.resolve(parsedArgs.project)); +let projectPath = projectConfig; +if (path.extname(projectConfig) !== ".json") { + projectConfig = normalizePath(path.join(projectConfig, "tsconfig.json")) +} else { + projectPath = normalizePath(path.dirname(projectConfig)); +} + + +let watched: Array<{ + watcher: fs.FSWatcher, + path: string, +}> = []; + +function watch(rootDir: string) { + if (parsedArgs.watch) { + let newWatched: Array; + if (parsedArgs.default) { + newWatched = parsedArgs.default; + } else { + newWatched = [rootDir]; + } + if(watched.length != newWatched.length || !watched.every((v, index) => v.path === newWatched[index])) { + watched.forEach(f => f.watcher.close()); + watched = newWatched.map(f => ({ + path: f, + watcher: fs.watch(f, { persistent: true, recursive: true }, cancelAndRestart), + })) + } + + } +} +let lastRunCancellation:CancellationToken = { isCancelled: false } +async function delay(ms:number) { + return new Promise(r => setTimeout(r, ms)); +} +function cancelAndRestart(event: fs.WatchEventType, filename: string) { + console.log(event, filename) + lastRunCancellation.isCancelled = true; + lastRunCancellation = { isCancelled: false }; + main(lastRunCancellation, 50); +} +async function main(cancellationToken: CancellationToken, msDelay: number) { + await delay(msDelay); + if(cancellationToken.isCancelled) return; + + console.log("Detected changes rebuilding") + + const tsconfig = ts.readConfigFile(projectConfig, ts.sys.readFile); + const parsed = ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, "./"); + const options = parsed.options; + const rootDir = options.rootDir ? normalizePath(path.resolve(path.join(projectPath, options.rootDir))) : projectPath; + const files = parsedArgs.default ?? readAllFiles(rootDir, /.*\.ts/).filter(t => !/[\\/]node_modules[\\/]/.exec(t)); + + watch(rootDir); + if(cancellationToken.isCancelled) return; + await transformProjectFiles(rootDir, files, options, cancellationToken); +} +main(lastRunCancellation, 0); + +type CancellationToken = { isCancelled: boolean }; +async function transformProjectFiles(rootDir: string, files: string[], options: ts.CompilerOptions, cancellationToken: CancellationToken) { + + const declarationDir = parsedArgs.declarationDir ? normalizePath(path.resolve(parsedArgs.declarationDir)) : + options.outDir ? normalizePath(path.resolve(options.outDir)) : + undefined; + for (let file of files) { + try { + const source = await fsp.readFile(file, { encoding: "utf8" }); + if(cancellationToken.isCancelled) return; + const actualDeclaration = transformFile(file, source, [], [], options, ts.ModuleKind.ESNext); + const output = + declarationDir? changeAnyExtension(file.replace(rootDir, declarationDir), ".d.ts"): + changeAnyExtension(file, ".d.ts"); + await ensureDir(path.dirname(output)); + await fsp.writeFile(output, actualDeclaration.code); + } catch (e) { + console.error(`Failed to transform: ${file}`, e) + } + } + return { rootDir }; +} \ No newline at end of file diff --git a/external-declarations/src/test-runner/cli-arg-config.ts b/external-declarations/src/test-runner/cli-arg-config.ts new file mode 100644 index 0000000000000..07d00c7cf8ad2 --- /dev/null +++ b/external-declarations/src/test-runner/cli-arg-config.ts @@ -0,0 +1,17 @@ +import { parserConfiguration, ArgType } from "../utils/cli-parser"; + +export const testRunnerCLIConfiguration = parserConfiguration({ + default: { + type: ArgType.String(), + description: "Test filter to run", + }, + type: { + type: ArgType.Enum("all", "tsc", "i"), + description: "Type of run (Typescript, all, or isolated)", + }, + shard: ArgType.Number(), + shardCount: ArgType.Number(), + histFolder: ArgType.String(), + libPath: ArgType.String(), + rootPaths: ArgType.StringArray(), +}) diff --git a/external-declarations/src/test-runner/excluded-ts-tests.ts b/external-declarations/src/test-runner/excluded-ts-tests.ts new file mode 100644 index 0000000000000..257e34e69c4d7 --- /dev/null +++ b/external-declarations/src/test-runner/excluded-ts-tests.ts @@ -0,0 +1,21 @@ +export const excludedTsTests = new Set([ + // These two tests contain a declaration error + // A variable that is not of a literal type is used as a computed property name + // TS will error on this and will not merge the overloads to a singe symbol + // This means TS will not remove the implementation overload + // + // The external declaration emitter will use the variable name to merge symbols. + "computedPropertyNamesOnOverloads_ES5", + "computedPropertyNamesOnOverloads_ES6", + // Symbols are merged across files and excluded. We can't do cross file analysis + "jsFileCompilationDuplicateFunctionImplementation", + "jsFileCompilationDuplicateFunctionImplementationFileOrderReversed", + // Output emitted to same file test ios not of interest for isolated declarations + "filesEmittingIntoSameOutput", + // Error in TS, but excludes implementation in declarations. + // Generating same output if we have an error is best effort + "overloadsInDifferentContainersDisagreeOnAmbient", + // The function is elided because the eval function is merged with eval from libs into a single symbol + // We can't reproduce this behavior + "parserStrictMode8", +]); \ No newline at end of file diff --git a/external-declarations/src/test-runner/parallel-run.ts b/external-declarations/src/test-runner/parallel-run.ts new file mode 100644 index 0000000000000..f8b779162981c --- /dev/null +++ b/external-declarations/src/test-runner/parallel-run.ts @@ -0,0 +1,82 @@ +import * as fs from 'fs' +import * as path from 'path' +import * as childProcess from "child_process"; +import { parseArgs } from '../utils/cli-parser'; +import { testRunnerCLIConfiguration } from './cli-arg-config'; + +type ExecuteResult = { + error: childProcess.ExecException | null + stdout: string, + stderr: string, +} + +function exec(cmd: string, dir: string, onStdOut: (s: string) => void) { + return new Promise((resolve) => { + console.log(`In ${dir} Executing: ${cmd}`); + + const ls = childProcess.spawn(cmd, [], { + cwd: path.resolve(path.join(process.cwd(), dir)), + shell: true + }); + let stdout = "" + let stderr = "" + ls.stdout.on('data', function (data) { + if(!onStdOut) { + process.stdout.write(data.toString()); + } else { + onStdOut(data.toString()); + } + stdout += data.toString(); + }); + + ls.stderr.on('data', function (data) { + process.stderr.write(data.toString()); + stderr += data.toString(); + }); + + ls.on('error', function(err) { + console.log(err); + }) + ls.on('exit', function (code) { + console.log('exited:' + code?.toString()); + resolve({ + error: !code ? null : Object.assign(new Error(""), { + code, + cmd: cmd, + }), + stderr, + stdout + }) + }); + }) +} + +const { value: parsedArgs, printUsageOnErrors } = parseArgs(process.argv.slice(2), testRunnerCLIConfiguration); +printUsageOnErrors(); + +const shardCount = parsedArgs.shardCount ?? 6; + +async function main() { + let runCount = 0; + const date = new Date(); + const histFolder = `${date.toISOString().replace(/:/g, "-")}-${parsedArgs.type}`; + const commandLine = `node ./build/test-runner/test-runner-main.js --histFolder=${histFolder} ${process.argv.slice(2).join(" ")} `; + let lastWrite = new Date().getTime(); + const startTime = new Date().getTime(); + const elapsedTime = (now: number) => `${((now - startTime) / 1000 / 60).toFixed(2)} minutes` + const promisees = Array.from({ length: shardCount}).map(async (_, index) => { + await exec(commandLine + ` --shard=${index}`, "./", out => { + runCount += (out.match(/Ran:/g) || []).length; + if(new Date().getTime() - lastWrite > 2000) { + lastWrite = new Date().getTime() + console.log(`Run count: ${runCount} after ${elapsedTime(lastWrite)}`); + } + }); + console.log(`Shard ${index} completed`); + }); + await Promise.all(promisees); + const endTime = new Date().getTime(); + console.log(`Took ${elapsedTime(endTime)} to complete ${runCount}`) +} + +main(); \ No newline at end of file diff --git a/external-declarations/src/test-runner/test-runner-main.ts b/external-declarations/src/test-runner/test-runner-main.ts new file mode 100644 index 0000000000000..20f6a6b7838fc --- /dev/null +++ b/external-declarations/src/test-runner/test-runner-main.ts @@ -0,0 +1,138 @@ +import 'source-map-support/register'; +import * as path from 'path' +import * as fs from 'fs/promises' +import { loadTestCase, runTypeScript, runIsolated, FileContent } from "./utils"; +import { IO } from './tsc-infrastructure/io'; +import { changeExtension } from './tsc-infrastructure/vpath'; +import { CompilerSettings, TestCaseContent } from './tsc-infrastructure/test-file-parser'; + +import * as ts from 'typescript' +import { normalizePath, removeExtension } from '../compiler/path-utils'; +import { excludedTsTests } from './excluded-ts-tests'; +import { getFileBasedTestConfigurationDescription, getFileBasedTestConfigurations } from './tsc-infrastructure/vary-by'; +import { setCompilerOptionsFromHarnessSetting } from './tsc-infrastructure/compiler-run'; +import { parseArgs } from '../utils/cli-parser'; +import { testRunnerCLIConfiguration } from './cli-arg-config'; +import { addToQueue, ensureDir, flushQueue, readAllFiles } from '../utils/fs-utils'; + + +const excludeFilter =/\/fourslash\//; + +const { value: parsedArgs, printUsageOnErrors } = parseArgs(process.argv.slice(2), testRunnerCLIConfiguration); + +printUsageOnErrors(); + +const shard = parsedArgs.shard +const shardCount = parsedArgs.shardCount +let prefix: string | undefined = undefined; +const prefixed = parsedArgs.default && /(?[0-9]{5})-(((?.*)\.(?(.*=.*)+)(\.d\.ts))|(?.*))/.exec(parsedArgs.default); +let testVersionFilter: string | undefined = undefined; +if(prefixed) { + prefix = prefixed.groups?.index; + parsedArgs.default = prefixed.groups?.name ?? prefixed.groups?.nameSimple; + testVersionFilter = prefixed.groups?.options; +} + +const rootCasePaths = parsedArgs.rootPaths ?? [ './tests/sources' ] +const libFolder = parsedArgs.libPath ?? path.join(rootCasePaths[0], "../lib") + +const filter = parsedArgs.default ? new RegExp(parsedArgs.default) : /.*\.ts/ +const runType = + parsedArgs.type === "all" ? { tsc: true, isolated: true } : + parsedArgs.type === "tsc" ? { tsc: true, isolated: false } : + { tsc: false, isolated: true }; + +const allTests = rootCasePaths + .map(r => readAllFiles(r, filter)) + .flat() + .filter(f => !excludeFilter.exec(f)); + +(ts as any).Debug.enableDebugInfo(); + +const date = new Date(); +const historical = (parsedArgs.histFolder && `/${parsedArgs.histFolder}/`) ?? `/${date.toISOString().replace(/:/g, "-")}-${parsedArgs.type}/`; + +function pad(num: number, size: number) { return ('000000000' + num).substr(-size); } + +async function main() { + + const libFiles = (await fs.readdir(libFolder)).map(n => normalizePath(path.join("/.lib", n))); + + const testsPerShared = shardCount && Math.round(allTests.length / shardCount); + const [start, end] = shard == undefined || shardCount == undefined || testsPerShared == undefined ? + [0, allTests.length] : + [shard * testsPerShared, (shard == shardCount - 1) ? allTests.length : (shard + 1) * testsPerShared]; + + for (let count = start; count < end; count++) { + const testFile = normalizePath(allTests[count]); + const testFileNoExtension = removeExtension(path.basename(testFile), path.extname(testFile)); + if(excludedTsTests.has(testFileNoExtension)) { + continue; + } + const data = await loadTestCase(testFile); + const variedConfiguration = getFileBasedTestConfigurations(data.settings) ?? [{}]; + for(const varConfig of variedConfiguration) { + const varConfigDescription = getFileBasedTestConfigurationDescription(varConfig); + if (testVersionFilter && varConfigDescription !== testVersionFilter) continue; + const file = (prefix ?? pad(count, 5)) + "-" + changeExtension(path.basename(testFile), varConfigDescription + ".d.ts"); + + if (runType.tsc) runAndWrite(path.join("./tsc-tests/$now/tsc", file), varConfig, runTypeScript); + + if (runType.isolated) runAndWrite(path.join("./tsc-tests/$now/isolated", file), varConfig, (t, s) => runIsolated(t, libFiles, s)); + + } + console.log(` Ran: ${pad(count, 5)}/${allTests.length}`) + + function runAndWrite(file: string, varySettings: CompilerSettings, fn: (data: TestCaseContent, opts: ts.CompilerOptions) => FileContent[]) { + const settings: ts.CompilerOptions = {}; + setCompilerOptionsFromHarnessSetting(data.settings, settings); + setCompilerOptionsFromHarnessSetting(varySettings, settings); + + + // Not supported + delete settings.outFile; + delete settings.out; + delete settings.outDir; + delete settings.declarationDir; + + const results = safeRun(d => fn(d, settings)); + const resultText = results + .flatMap(r => [ + "// " + r.fileName, + r.content + ]) + .join(IO.newLine()); + + if (allTests.length > 5) { + writeResults(normalizePath(file).replace("/$now/", historical), resultText); + } + writeResults(file, resultText); + } + + function safeRun(fn: (data: TestCaseContent) => FileContent[]): FileContent[] { + try { + return fn(data) + } catch (e) { + return [{ + fileName: path.basename(testFile), + content: ` +==== ERROR ==== +message: ${e.message}, +${e.stack}, + `, + }] + } + } + + async function writeResults(fileName: string, results: string) { + addToQueue(async () => { + const dirName = path.dirname(fileName); + await ensureDir(dirName); + await fs.writeFile(fileName, results); + console.log(`Written: ${pad(count, 5)}/${allTests.length}`) + }); + } + } + await flushQueue(); +} +main(); \ No newline at end of file diff --git a/external-declarations/src/test-runner/tsc-infrastructure/collections.ts b/external-declarations/src/test-runner/tsc-infrastructure/collections.ts new file mode 100644 index 0000000000000..dbd518538a657 --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/collections.ts @@ -0,0 +1,326 @@ +import * as ts from '../../compiler/lang-utils' + +export interface SortOptions { + comparer: (a: T, b: T) => number; + sort: "insertion" | "comparison"; +} + +export class SortedMap { + private _comparer: (a: K, b: K) => number; + private _keys: K[] = []; + private _values: V[] = []; + private _order: number[] | undefined; + private _version = 0; + private _copyOnWrite = false; + + constructor(comparer: ((a: K, b: K) => number) | SortOptions, iterable?: Iterable<[K, V]>) { + this._comparer = typeof comparer === "object" ? comparer.comparer : comparer; + this._order = typeof comparer === "object" && comparer.sort === "insertion" ? [] : undefined; + if (iterable) { + const iterator = getIterator(iterable); + try { + for (let i = nextResult(iterator); i; i = nextResult(iterator)) { + const [key, value] = i.value; + this.set(key, value); + } + } + finally { + closeIterator(iterator); + } + } + } + + public get size() { + return this._keys.length; + } + + public get comparer() { + return this._comparer; + } + + public get [Symbol.toStringTag]() { + return "SortedMap"; + } + + public has(key: K) { + return ts.binarySearch(this._keys, key, ts.identity, this._comparer) >= 0; + } + + public get(key: K) { + const index = ts.binarySearch(this._keys, key, ts.identity, this._comparer); + return index >= 0 ? this._values[index] : undefined; + } + + public getEntry(key: K): [ K, V ] | undefined { + const index = ts.binarySearch(this._keys, key, ts.identity, this._comparer); + return index >= 0 ? [ this._keys[index], this._values[index] ] : undefined; + } + + public set(key: K, value: V) { + const index = ts.binarySearch(this._keys, key, ts.identity, this._comparer); + if (index >= 0) { + this._values[index] = value; + } + else { + this.writePreamble(); + insertAt(this._keys, ~index, key); + insertAt(this._values, ~index, value); + if (this._order) insertAt(this._order, ~index, this._version); + this.writePostScript(); + } + return this; + } + + public delete(key: K) { + const index = ts.binarySearch(this._keys, key, ts.identity, this._comparer); + if (index >= 0) { + this.writePreamble(); + ts.orderedRemoveItemAt(this._keys, index); + ts.orderedRemoveItemAt(this._values, index); + if (this._order) ts.orderedRemoveItemAt(this._order, index); + this.writePostScript(); + return true; + } + return false; + } + + public clear() { + if (this.size > 0) { + this.writePreamble(); + this._keys.length = 0; + this._values.length = 0; + if (this._order) this._order.length = 0; + this.writePostScript(); + } + } + + public forEach(callback: (value: V, key: K, collection: this) => void, thisArg?: any) { + const keys = this._keys; + const values = this._values; + const indices = this.getIterationOrder(); + const version = this._version; + this._copyOnWrite = true; + try { + if (indices) { + for (const i of indices) { + callback.call(thisArg, values[i], keys[i], this); + } + } + else { + for (let i = 0; i < keys.length; i++) { + callback.call(thisArg, values[i], keys[i], this); + } + } + } + finally { + if (version === this._version) { + this._copyOnWrite = false; + } + } + } + + public * keys() { + const keys = this._keys; + const indices = this.getIterationOrder(); + const version = this._version; + this._copyOnWrite = true; + try { + if (indices) { + for (const i of indices) { + yield keys[i]; + } + } + else { + yield* keys; + } + } + finally { + if (version === this._version) { + this._copyOnWrite = false; + } + } + } + + public * values() { + const values = this._values; + const indices = this.getIterationOrder(); + const version = this._version; + this._copyOnWrite = true; + try { + if (indices) { + for (const i of indices) { + yield values[i]; + } + } + else { + yield* values; + } + } + finally { + if (version === this._version) { + this._copyOnWrite = false; + } + } + } + + public * entries() { + const keys = this._keys; + const values = this._values; + const indices = this.getIterationOrder(); + const version = this._version; + this._copyOnWrite = true; + try { + if (indices) { + for (const i of indices) { + yield [keys[i], values[i]] as [K, V]; + } + } + else { + for (let i = 0; i < keys.length; i++) { + yield [keys[i], values[i]] as [K, V]; + } + } + } + finally { + if (version === this._version) { + this._copyOnWrite = false; + } + } + } + + public [Symbol.iterator]() { + return this.entries(); + } + + private writePreamble() { + if (this._copyOnWrite) { + this._keys = this._keys.slice(); + this._values = this._values.slice(); + if (this._order) this._order = this._order.slice(); + this._copyOnWrite = false; + } + } + + private writePostScript() { + this._version++; + } + + private getIterationOrder() { + if (this._order) { + const order = this._order; + return this._order + .map((_, i) => i) + .sort((x, y) => order[x] - order[y]); + } + return undefined; + } +} + +export function insertAt(array: T[], index: number, value: T): void { + if (index === 0) { + array.unshift(value); + } + else if (index === array.length) { + array.push(value); + } + else { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; + } +} + +export function getIterator(iterable: Iterable): Iterator { + return iterable[Symbol.iterator](); +} + +export function nextResult(iterator: Iterator): IteratorResult | undefined { + const result = iterator.next(); + return result.done ? undefined : result; +} + +export function closeIterator(iterator: Iterator) { + const fn = iterator.return; + if (typeof fn === "function") fn.call(iterator); +} + +/** + * A collection of metadata that supports inheritance. + */ +export class Metadata { + private static readonly _undefinedValue = {}; + private _parent: Metadata | undefined; + private _map: { [key: string]: any }; + private _version = 0; + private _size = -1; + private _parentVersion: number | undefined; + + constructor(parent?: Metadata) { + this._parent = parent; + this._map = Object.create(parent ? parent._map : null); // eslint-disable-line no-null/no-null + } + + public get size(): number { + if (this._size === -1 || (this._parent && this._parent._version !== this._parentVersion)) { + let size = 0; + for (const _ in this._map) size++; + this._size = size; + if (this._parent) { + this._parentVersion = this._parent._version; + } + } + return this._size; + } + + public get parent() { + return this._parent; + } + + public has(key: string): boolean { + return this._map[Metadata._escapeKey(key)] !== undefined; + } + + public get(key: string): any { + const value = this._map[Metadata._escapeKey(key)]; + return value === Metadata._undefinedValue ? undefined : value; + } + + public set(key: string, value: any): this { + this._map[Metadata._escapeKey(key)] = value === undefined ? Metadata._undefinedValue : value; + this._size = -1; + this._version++; + return this; + } + + public delete(key: string): boolean { + const escapedKey = Metadata._escapeKey(key); + if (this._map[escapedKey] !== undefined) { + delete this._map[escapedKey]; + this._size = -1; + this._version++; + return true; + } + return false; + } + + public clear(): void { + this._map = Object.create(this._parent ? this._parent._map : null); // eslint-disable-line no-null/no-null + this._size = -1; + this._version++; + } + + public forEach(callback: (value: any, key: string, map: this) => void) { + for (const key in this._map) { + callback(this._map[key], Metadata._unescapeKey(key), this); + } + } + + private static _escapeKey(text: string) { + return (text.length >= 2 && text.charAt(0) === "_" && text.charAt(1) === "_" ? "_" + text : text); + } + + private static _unescapeKey(text: string) { + return (text.length >= 3 && text.charAt(0) === "_" && text.charAt(1) === "_" && text.charAt(2) === "_" ? text.slice(1) : text); + } +} diff --git a/external-declarations/src/test-runner/tsc-infrastructure/compiler-run.ts b/external-declarations/src/test-runner/tsc-infrastructure/compiler-run.ts new file mode 100644 index 0000000000000..db6a1632e5059 --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/compiler-run.ts @@ -0,0 +1,231 @@ +import { CompilerOptions, Diagnostic } from "typescript"; +import ts = require("typescript"); +import { hasProperty } from "../../compiler/debug"; +import { trimString, startsWith, mapDefined, map, compareStringsCaseSensitive } from "../../compiler/lang-utils"; +import * as opts from "./options"; +import * as TestCaseParser from "./test-file-parser"; +import * as vfs from "./vfs"; +import * as vpath from "./vpath"; +import { parseCustomTypeOption, parseListTypeOption } from "./options"; +import { fileExtensionIs, getNormalizedAbsolutePath, normalizeSlashes, toPath } from "../../compiler/path-utils"; +import { cloneCompilerOptions, getEmitScriptTarget } from "../../compiler/utils"; +import * as documents from './test-document'; +import { createGetCanonicalFileName } from "../../compiler/path-utils"; +import * as compiler from './compiler'; +import * as fakes from './fakesHosts'; +import { IO } from "./io"; + +interface HarnessOptions { + useCaseSensitiveFileNames?: boolean; + includeBuiltFile?: string; + baselineFile?: string; + libFiles?: string; + noTypesAndSymbols?: boolean; +} + +// Additional options not already in ts.optionDeclarations +const harnessOptionDeclarations: opts.CommandLineOption[] = [ + { name: "allowNonTsExtensions", type: "boolean", defaultValueDescription: false }, + { name: "useCaseSensitiveFileNames", type: "boolean", defaultValueDescription: false }, + { name: "baselineFile", type: "string" }, + { name: "includeBuiltFile", type: "string" }, + { name: "fileName", type: "string" }, + { name: "libFiles", type: "string" }, + { name: "noErrorTruncation", type: "boolean", defaultValueDescription: false }, + { name: "suppressOutputPathCheck", type: "boolean", defaultValueDescription: false }, + { name: "noImplicitReferences", type: "boolean", defaultValueDescription: false }, + { name: "currentDirectory", type: "string" }, + { name: "symlink", type: "string" }, + { name: "link", type: "string" }, + { name: "noTypesAndSymbols", type: "boolean", defaultValueDescription: false }, + // Emitted js baseline will print full paths for every output file + { name: "fullEmitPaths", type: "boolean", defaultValueDescription: false }, +]; + +let optionsIndex: Map; +function getCommandLineOption(name: string): opts.CommandLineOption | undefined { + if (!optionsIndex) { + optionsIndex = new Map(); + const optionDeclarations = harnessOptionDeclarations.concat(opts.optionDeclarations); + for (const option of optionDeclarations) { + optionsIndex.set(option.name.toLowerCase(), option); + } + } + return optionsIndex.get(name.toLowerCase()); +} +export function setCompilerOptionsFromHarnessSetting(settings: TestCaseParser.CompilerSettings, options: CompilerOptions & HarnessOptions): void { + for (const name in settings) { + if (hasProperty(settings, name)) { + const value = settings[name]; + if (value === undefined) { + throw new Error(`Cannot have undefined value for compiler option '${name}'.`); + } + const option = getCommandLineOption(name); + if (option) { + const errors: Diagnostic[] = []; + options[option.name] = optionValue(option, value, errors); + if (errors.length > 0) { + throw new Error(`Unknown value '${value}' for compiler option '${name}'.`); + } + } + } + } +} + + +function optionValue(option: opts.CommandLineOption, value: string, errors: Diagnostic[]): any { + switch (option.type) { + case "boolean": + return value.toLowerCase() === "true"; + case "string": + return value; + case "number": { + const numverValue = parseInt(value, 10); + if (isNaN(numverValue)) { + throw new Error(`Value must be a number, got: ${JSON.stringify(value)}`); + } + return numverValue; + } + // If not a primitive, the possible types are specified in what is effectively a map of options. + case "list": + return parseListTypeOption(option, value, errors); + default: + return parseCustomTypeOption(option as opts.CommandLineOptionOfCustomType, value, errors); + } +} + +export interface TestFile { + unitName: string; + content: string; + fileOptions?: any; +} + +export function compileFiles( + inputFiles: TestFile[], + otherFiles: TestFile[], + harnessSettings: TestCaseParser.CompilerSettings | undefined, + compilerOptions: ts.CompilerOptions | undefined, + // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file + currentDirectory: string | undefined, + symlinks?: vfs.FileSet +): compiler.CompilationResult { + const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? cloneCompilerOptions(compilerOptions) : { noResolve: false }; + options.target = getEmitScriptTarget(options); + options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed; + options.noErrorTruncation = true; + options.skipDefaultLibCheck = typeof options.skipDefaultLibCheck === "undefined" ? true : options.skipDefaultLibCheck; + + if (typeof currentDirectory === "undefined") { + currentDirectory = vfs.srcFolder; + } + + // Parse settings + if (harnessSettings) { + setCompilerOptionsFromHarnessSetting(harnessSettings, options); + } + if (options.rootDirs) { + options.rootDirs = map(options.rootDirs, d => getNormalizedAbsolutePath(d, currentDirectory)); + } + + const useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : true; + const programFileNames = inputFiles.map(file => file.unitName).filter(fileName => !fileExtensionIs(fileName, ts.Extension.Json)); + + // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. + // Treat them as library files, so include them in build, but not in baselines. + if (options.includeBuiltFile) { + programFileNames.push(vpath.combine(vfs.builtFolder, options.includeBuiltFile)); + } + + // Files from tests\lib that are requested by "@libFiles" + if (options.libFiles) { + for (const fileName of options.libFiles.split(",")) { + programFileNames.push(vpath.combine(vfs.testLibFolder, fileName)); + } + + } + const docs = inputFiles.concat(otherFiles).map(documents.TextDocument.fromTestFile); + const fs = vfs.createFromFileSystem(IO, !useCaseSensitiveFileNames, { documents: docs, cwd: currentDirectory }); + if (symlinks) { + fs.apply(symlinks); + } + const host = new fakes.CompilerHost(fs, options); + const result = compiler.compileFiles(host, programFileNames, options); + result.symlinks = symlinks; + return result; +} + + +export function* iterateOutputs(outputFiles: Iterable): IterableIterator<[string, string]> { + // Collect, test, and sort the fileNames + const files = Array.from(outputFiles); + files.slice().sort((a, b) => compareStringsCaseSensitive(cleanName(a.file), cleanName(b.file))); + const dupeCase = new Map(); + // Yield them + for (const outputFile of files) { + yield [checkDuplicatedFileName(outputFile.file, dupeCase), "/*====== " + outputFile.file + " ======*/\r\n" + Utils.removeByteOrderMark(outputFile.text)]; + } + + function cleanName(fn: string) { + const lastSlash = normalizeSlashes(fn).lastIndexOf("/"); + return fn.substr(lastSlash + 1).toLowerCase(); + } +} + +function checkDuplicatedFileName(resultName: string, dupeCase: Map): string { + resultName = sanitizeTestFilePath(resultName); + if (dupeCase.has(resultName)) { + // A different baseline filename should be manufactured if the names differ only in case, for windows compat + const count = 1 + dupeCase.get(resultName)!; + dupeCase.set(resultName, count); + resultName = `${resultName}.dupe${count}`; + } + else { + dupeCase.set(resultName, 0); + } + return resultName; +} + +export function sanitizeTestFilePath(name: string) { + const path = toPath(normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/"), "", Utils.canonicalizeForHarness); + if (startsWith(path, "/")) { + return path.substring(1); + } + return path; +} + +export namespace Utils { + export const canonicalizeForHarness = createGetCanonicalFileName(/*caseSensitive*/ false); // This is done so tests work on windows _and_ linux + + export function removeByteOrderMark(text: string): string { + const length = getByteOrderMarkLength(text); + return length ? text.slice(length) : text; + } + + export function getByteOrderMarkLength(text: string): number { + if (text.length >= 1) { + const ch0 = text.charCodeAt(0); + if (ch0 === 0xfeff) return 1; + if (ch0 === 0xfe) return text.length >= 2 && text.charCodeAt(1) === 0xff ? 2 : 0; + if (ch0 === 0xff) return text.length >= 2 && text.charCodeAt(1) === 0xfe ? 2 : 0; + if (ch0 === 0xef) return text.length >= 3 && text.charCodeAt(1) === 0xbb && text.charCodeAt(2) === 0xbf ? 3 : 0; + } + return 0; + } + + function checkDuplicatedFileName(resultName: string, dupeCase: Map): string { + resultName = sanitizeTestFilePath(resultName); + if (dupeCase.has(resultName)) { + // A different baseline filename should be manufactured if the names differ only in case, for windows compat + const count = 1 + dupeCase.get(resultName)!; + dupeCase.set(resultName, count); + resultName = `${resultName}.dupe${count}`; + } + else { + dupeCase.set(resultName, 0); + } + return resultName; + } + export function addUTF8ByteOrderMark(text: string) { + return getByteOrderMarkLength(text) === 0 ? "\u00EF\u00BB\u00BF" + text : text; + } +} \ No newline at end of file diff --git a/external-declarations/src/test-runner/tsc-infrastructure/compiler.ts b/external-declarations/src/test-runner/tsc-infrastructure/compiler.ts new file mode 100644 index 0000000000000..5d39f71f97045 --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/compiler.ts @@ -0,0 +1,270 @@ +import * as ts from "typescript"; +import * as lang from "../../compiler/lang-utils"; +import * as vpath from "./vpath"; +import * as documents from "./test-document"; +import * as vfs from "./vfs"; +import * as collections from "./collections"; +import * as fakes from './fakesHosts'; +import { getDeclarationEmitExtensionForPath, getOutputExtension } from "../../compiler/utils"; +import { fileExtensionIs } from "../../compiler/path-utils"; + +/** + * Test harness compiler functionality. + */ + +export interface Project { + file: string; + config?: ts.ParsedCommandLine; + errors?: ts.Diagnostic[]; +} + +export function readProject(host: fakes.ParseConfigHost, project: string | undefined, existingOptions?: ts.CompilerOptions): Project | undefined { + if (project) { + project = vpath.isTsConfigFile(project) ? project : vpath.combine(project, "tsconfig.json"); + } + else { + [project] = host.vfs.scanSync(".", "ancestors-or-self", { + accept: (path, stats) => stats.isFile() && host.vfs.stringComparer(vpath.basename(path), "tsconfig.json") === 0 + }); + } + + if (project) { + // TODO(rbuckton): Do we need to resolve this? Resolving breaks projects tests. + // project = vpath.resolve(host.vfs.currentDirectory, project); + + // read the config file + const readResult = ts.readConfigFile(project, path => host.readFile(path)); + if (readResult.error) { + return { file: project, errors: [readResult.error] }; + } + + // parse the config file + const config = ts.parseJsonConfigFileContent(readResult.config, host, vpath.dirname(project), existingOptions); + return { file: project, errors: config.errors, config }; + } +} + +/** + * Correlates compilation inputs and outputs + */ +export interface CompilationOutput { + readonly inputs: readonly documents.TextDocument[]; + readonly js: documents.TextDocument | undefined; + readonly dts: documents.TextDocument | undefined; + readonly map: documents.TextDocument | undefined; +} + +export class CompilationResult { + public readonly host: fakes.CompilerHost; + public readonly program: ts.Program | undefined; + public readonly result: ts.EmitResult | undefined; + public readonly options: ts.CompilerOptions; + public readonly diagnostics: readonly ts.Diagnostic[]; + public readonly js: ReadonlyMap; + public readonly dts: ReadonlyMap; + public readonly maps: ReadonlyMap; + public symlinks?: vfs.FileSet; // Location to store original symlinks so they may be used in both original and declaration file compilations + + private _inputs: documents.TextDocument[] = []; + private _inputsAndOutputs: collections.SortedMap; + + constructor(host: fakes.CompilerHost, options: ts.CompilerOptions, program: ts.Program | undefined, result: ts.EmitResult | undefined, diagnostics: readonly ts.Diagnostic[]) { + this.host = host; + this.program = program; + this.result = result; + this.diagnostics = diagnostics; + this.options = program ? program.getCompilerOptions() : options; + + // collect outputs + const js = this.js = new collections.SortedMap({ comparer: this.vfs.stringComparer, sort: "insertion" }); + const dts = this.dts = new collections.SortedMap({ comparer: this.vfs.stringComparer, sort: "insertion" }); + const maps = this.maps = new collections.SortedMap({ comparer: this.vfs.stringComparer, sort: "insertion" }); + for (const document of this.host.outputs) { + if (vpath.isJavaScript(document.file) || fileExtensionIs(document.file, ts.Extension.Json)) { + js.set(document.file, document); + } + else if (vpath.isDeclaration(document.file)) { + dts.set(document.file, document); + } + else if (vpath.isSourceMap(document.file)) { + maps.set(document.file, document); + } + } + + // correlate inputs and outputs + this._inputsAndOutputs = new collections.SortedMap({ comparer: this.vfs.stringComparer, sort: "insertion" }); + if (program) { + if (this.options.out || this.options.outFile) { + const outFile = vpath.resolve(this.vfs.cwd(), this.options.outFile || this.options.out); + const inputs: documents.TextDocument[] = []; + for (const sourceFile of program.getSourceFiles()) { + if (sourceFile) { + const input = new documents.TextDocument(sourceFile.fileName, sourceFile.text); + this._inputs.push(input); + if (!vpath.isDeclaration(sourceFile.fileName)) { + inputs.push(input); + } + } + } + + const outputs: CompilationOutput = { + inputs, + js: js.get(outFile), + dts: dts.get(vpath.changeExtension(outFile, ".d.ts")), + map: maps.get(outFile + ".map") + }; + + if (outputs.js) this._inputsAndOutputs.set(outputs.js.file, outputs); + if (outputs.dts) this._inputsAndOutputs.set(outputs.dts.file, outputs); + if (outputs.map) this._inputsAndOutputs.set(outputs.map.file, outputs); + + for (const input of inputs) { + this._inputsAndOutputs.set(input.file, outputs); + } + } + else { + for (const sourceFile of program.getSourceFiles()) { + if (sourceFile) { + const input = new documents.TextDocument(sourceFile.fileName, sourceFile.text); + this._inputs.push(input); + if (!vpath.isDeclaration(sourceFile.fileName)) { + const extname = getOutputExtension(sourceFile.fileName, this.options); + const outputs: CompilationOutput = { + inputs: [input], + js: js.get(this.getOutputPath(sourceFile.fileName, extname)), + dts: dts.get(this.getOutputPath(sourceFile.fileName, getDeclarationEmitExtensionForPath(sourceFile.fileName))), + map: maps.get(this.getOutputPath(sourceFile.fileName, extname + ".map")) + }; + + this._inputsAndOutputs.set(sourceFile.fileName, outputs); + if (outputs.js) this._inputsAndOutputs.set(outputs.js.file, outputs); + if (outputs.dts) this._inputsAndOutputs.set(outputs.dts.file, outputs); + if (outputs.map) this._inputsAndOutputs.set(outputs.map.file, outputs); + } + } + } + } + } + } + + public get vfs(): vfs.FileSystem { + return this.host.vfs; + } + + public get inputs(): readonly documents.TextDocument[] { + return this._inputs; + } + + public get outputs(): readonly documents.TextDocument[] { + return this.host.outputs; + } + + public get traces(): readonly string[] { + return this.host.traces; + } + + public get emitSkipped(): boolean { + return this.result && this.result.emitSkipped || false; + } + + public get singleFile(): boolean { + return !!this.options.outFile || !!this.options.out; + } + + public get commonSourceDirectory(): string { + const common = this.program && (this.program as any).getCommonSourceDirectory() || ""; + return common && vpath.combine(this.vfs.cwd(), common); + } + + public getInputsAndOutputs(path: string): CompilationOutput | undefined { + return this._inputsAndOutputs.get(vpath.resolve(this.vfs.cwd(), path)); + } + + public getInputs(path: string): readonly documents.TextDocument[] | undefined { + const outputs = this.getInputsAndOutputs(path); + return outputs && outputs.inputs; + } + + public getOutput(path: string, kind: "js" | "dts" | "map"): documents.TextDocument | undefined { + const outputs = this.getInputsAndOutputs(path); + return outputs && outputs[kind]; + } + + public getOutputPath(path: string, ext: string): string { + if (this.options.outFile || this.options.out) { + path = vpath.resolve(this.vfs.cwd(), this.options.outFile || this.options.out); + } + else { + path = vpath.resolve(this.vfs.cwd(), path); + const outDir = ext === ".d.ts" || ext === ".json.d.ts" || ext === ".d.mts" || ext === ".d.cts" ? this.options.declarationDir || this.options.outDir : this.options.outDir; + if (outDir) { + const common = this.commonSourceDirectory; + if (common) { + path = vpath.relative(common, path, this.vfs.ignoreCase); + path = vpath.combine(vpath.resolve(this.vfs.cwd(), this.options.outDir), path); + } + } + } + return vpath.changeExtension(path, ext); + } + + public getNumberOfJsFiles(includeJson: boolean) { + if (includeJson) { + return this.js.size; + } + else { + let count = this.js.size; + this.js.forEach(document => { + if (fileExtensionIs(document.file, ts.Extension.Json)) { + count--; + } + }); + return count; + } + } +} + +export function compileFiles(host: fakes.CompilerHost, rootFiles: string[] | undefined, compilerOptions: ts.CompilerOptions): CompilationResult { + if (compilerOptions.project || !rootFiles || rootFiles.length === 0) { + const project = readProject(host.parseConfigHost, compilerOptions.project, compilerOptions); + if (project) { + if (project.errors && project.errors.length > 0) { + return new CompilationResult(host, compilerOptions, /*program*/ undefined, /*result*/ undefined, project.errors); + } + if (project.config) { + rootFiles = project.config.fileNames; + compilerOptions = project.config.options; + } + } + delete compilerOptions.project; + } + + // establish defaults (aligns with old harness) + if (compilerOptions.target === undefined && compilerOptions.module !== ts.ModuleKind.Node16 && compilerOptions.module !== ts.ModuleKind.NodeNext) compilerOptions.target = ts.ScriptTarget.ES3; + if (compilerOptions.newLine === undefined) compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; + if (compilerOptions.skipDefaultLibCheck === undefined) compilerOptions.skipDefaultLibCheck = true; + if (compilerOptions.noErrorTruncation === undefined) compilerOptions.noErrorTruncation = true; + + // pre-emit/post-emit error comparison requires declaration emit twice, which can be slow. If it's unlikely to flag any error consistency issues + // and if the test is running `skipLibCheck` - an indicator that we want the tets to run quickly - skip the before/after error comparison, too + const skipErrorComparison = lang.length(rootFiles) >= 100 || (!!compilerOptions.skipLibCheck && !!compilerOptions.declaration); + + const preProgram = !skipErrorComparison ? ts.createProgram(rootFiles || [], { ...compilerOptions, configFile: compilerOptions.configFile, traceResolution: false }, host) : undefined; + const preErrors = preProgram && ts.getPreEmitDiagnostics(preProgram); + + const program = ts.createProgram(rootFiles || [], compilerOptions, host); + const emitResult = program.emit(undefined, (fileName, text, writeByteOrderMark) => { + // If there are errors TS will ot emit declaration files. We want then regardless of errors. + if(!vpath.isAbsolute(fileName)) { + fileName = vpath.resolve(host.vfs.cwd(), fileName); + } + if(host.outputs.some(d => d.file === fileName)) return; + host.writeFile(fileName, text, writeByteOrderMark); + // @ts-expect-error We use forceDts emit documented flag + }, undefined, undefined,undefined, true); + const postErrors = ts.getPreEmitDiagnostics(program); + const longerErrors = lang.length(preErrors) > postErrors.length ? preErrors : postErrors; + const shorterErrors = longerErrors === preErrors ? postErrors : preErrors; + const errors = preErrors && (preErrors.length !== postErrors.length) ? [...shorterErrors!] : postErrors; + return new CompilationResult(host, compilerOptions, program, emitResult, errors); +} diff --git a/external-declarations/src/test-runner/tsc-infrastructure/fakesHosts.ts b/external-declarations/src/test-runner/tsc-infrastructure/fakesHosts.ts new file mode 100644 index 0000000000000..4498a0c5641a8 --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/fakesHosts.ts @@ -0,0 +1,409 @@ +import * as ts from 'typescript'; +import * as vfs from "./vfs"; +import * as vpath from "./vpath"; +import * as collections from './collections' +import * as documents from './test-document' +import { Utils } from './compiler-run'; +import { getNewLineCharacter } from '../../compiler/utils'; + + +/** + * Fake implementations of various compiler dependencies. + */ + + const processExitSentinel = new Error("System exit"); + + export interface SystemOptions { + executingFilePath?: string; + newLine?: "\r\n" | "\n"; + env?: Record; + } + + /** + * A fake `ts.System` that leverages a virtual file system. + */ + export class System implements ts.System { + public readonly vfs: vfs.FileSystem; + public readonly args: string[] = []; + public readonly output: string[] = []; + public readonly newLine: string; + public readonly useCaseSensitiveFileNames: boolean; + public exitCode: number | undefined; + + private readonly _executingFilePath: string | undefined; + private readonly _env: Record | undefined; + + constructor(vfs: vfs.FileSystem, { executingFilePath, newLine = "\r\n", env }: SystemOptions = {}) { + this.vfs = vfs.isReadonly ? vfs.shadow() : vfs; + this.useCaseSensitiveFileNames = !this.vfs.ignoreCase; + this.newLine = newLine; + this._executingFilePath = executingFilePath; + this._env = env; + } + + private testTerminalWidth = Number.parseInt(this.getEnvironmentVariable("TS_TEST_TERMINAL_WIDTH")); + getWidthOfTerminal = Number.isNaN(this.testTerminalWidth) ? undefined : () => this.testTerminalWidth; + + // Pretty output + writeOutputIsTTY() { + return true; + } + + public write(message: string) { + console.log(message); + this.output.push(message); + } + + public readFile(path: string) { + try { + const content = this.vfs.readFileSync(path, "utf8"); + return content === undefined ? undefined : Utils.removeByteOrderMark(content); + } + catch { + return undefined; + } + } + + public writeFile(path: string, data: string, writeByteOrderMark?: boolean): void { + this.vfs.mkdirpSync(vpath.dirname(path)); + this.vfs.writeFileSync(path, writeByteOrderMark ? Utils.addUTF8ByteOrderMark(data) : data); + } + + public deleteFile(path: string) { + this.vfs.unlinkSync(path); + } + + public fileExists(path: string) { + const stats = this._getStats(path); + return stats ? stats.isFile() : false; + } + + public directoryExists(path: string) { + const stats = this._getStats(path); + return stats ? stats.isDirectory() : false; + } + + public createDirectory(path: string): void { + this.vfs.mkdirpSync(path); + } + + public getCurrentDirectory() { + return this.vfs.cwd(); + } + + public getDirectories(path: string) { + const result: string[] = []; + try { + for (const file of this.vfs.readdirSync(path)) { + if (this.vfs.statSync(vpath.combine(path, file)).isDirectory()) { + result.push(file); + } + } + } + catch { /*ignore*/ } + return result; + } + + public readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] { + throw new Error("Not implemented"); + // return matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path)); + } + + public getAccessibleFileSystemEntries(path: string): vfs.FileSystemEntries { + const files: string[] = []; + const directories: string[] = []; + try { + for (const file of this.vfs.readdirSync(path)) { + try { + const stats = this.vfs.statSync(vpath.combine(path, file)); + if (stats.isFile()) { + files.push(file); + } + else if (stats.isDirectory()) { + directories.push(file); + } + } + catch { /*ignored*/ } + } + } + catch { /*ignored*/ } + return { files, directories }; + } + + public exit(exitCode?: number) { + this.exitCode = exitCode; + throw processExitSentinel; + } + + public getFileSize(path: string) { + const stats = this._getStats(path); + return stats && stats.isFile() ? stats.size : 0; + } + + public resolvePath(path: string) { + return vpath.resolve(this.vfs.cwd(), path); + } + + public getExecutingFilePath() { + if (this._executingFilePath === undefined) throw new Error("ts.notImplemented"); + return this._executingFilePath; + } + + public getModifiedTime(path: string) { + const stats = this._getStats(path); + return stats ? stats.mtime : undefined!; // TODO: GH#18217 + } + + public setModifiedTime(path: string, time: Date) { + this.vfs.utimesSync(path, time, time); + } + + public createHash(data: string): string { + return `${generateDjb2Hash(data)}-${data}`; + } + + public realpath(path: string) { + try { + return this.vfs.realpathSync(path); + } + catch { + return path; + } + } + + public getEnvironmentVariable(name: string): string { + return (this._env && this._env[name])!; // TODO: GH#18217 + } + + private _getStats(path: string) { + try { + return this.vfs.existsSync(path) ? this.vfs.statSync(path) : undefined; + } + catch { + return undefined; + } + } + + now() { + return new Date(this.vfs.time()); + } + } + + /** + * A fake `ts.ParseConfigHost` that leverages a virtual file system. + */ + export class ParseConfigHost implements ts.ParseConfigHost { + public readonly sys: System; + + constructor(sys: System | vfs.FileSystem) { + if (sys instanceof vfs.FileSystem) sys = new System(sys); + this.sys = sys; + } + + public get vfs() { + return this.sys.vfs; + } + + public get useCaseSensitiveFileNames() { + return this.sys.useCaseSensitiveFileNames; + } + + public fileExists(fileName: string): boolean { + return this.sys.fileExists(fileName); + } + + public directoryExists(directoryName: string): boolean { + return this.sys.directoryExists(directoryName); + } + + public readFile(path: string): string | undefined { + return this.sys.readFile(path); + } + + public readDirectory(path: string, extensions: string[], excludes: string[], includes: string[], depth: number): string[] { + return this.sys.readDirectory(path, extensions, excludes, includes, depth); + } + } + +/** + * A fake `ts.CompilerHost` that leverages a virtual file system. + */ + export class CompilerHost implements ts.CompilerHost { + public readonly sys: System; + public readonly defaultLibLocation: string; + public readonly outputs: documents.TextDocument[] = []; + private readonly _outputsMap: collections.SortedMap; + public readonly traces: string[] = []; + public readonly shouldAssertInvariants = false; + + private _setParentNodes: boolean; + private _sourceFiles: collections.SortedMap; + private _parseConfigHost: ParseConfigHost | undefined; + private _newLine: string; + + constructor(sys: System | vfs.FileSystem, options = ts.getDefaultCompilerOptions(), setParentNodes = false) { + if (sys instanceof vfs.FileSystem) sys = new System(sys); + this.sys = sys; + this.defaultLibLocation = sys.vfs.meta.get("defaultLibLocation") || ""; + this._newLine = getNewLineCharacter(options, () => this.sys.newLine); + this._sourceFiles = new collections.SortedMap({ comparer: sys.vfs.stringComparer, sort: "insertion" }); + this._setParentNodes = setParentNodes; + this._outputsMap = new collections.SortedMap(this.vfs.stringComparer); + } + + public get vfs() { + return this.sys.vfs; + } + + public get parseConfigHost() { + return this._parseConfigHost || (this._parseConfigHost = new ParseConfigHost(this.sys)); + } + + public getCurrentDirectory(): string { + return this.sys.getCurrentDirectory(); + } + + public useCaseSensitiveFileNames(): boolean { + return this.sys.useCaseSensitiveFileNames; + } + + public getNewLine(): string { + return this._newLine; + } + + public getCanonicalFileName(fileName: string): string { + return this.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + + public deleteFile(fileName: string) { + this.sys.deleteFile(fileName); + } + + public fileExists(fileName: string): boolean { + return this.sys.fileExists(fileName); + } + + public directoryExists(directoryName: string): boolean { + return this.sys.directoryExists(directoryName); + } + + public getModifiedTime(fileName: string) { + return this.sys.getModifiedTime(fileName); + } + + public setModifiedTime(fileName: string, time: Date) { + return this.sys.setModifiedTime(fileName, time); + } + + public getDirectories(path: string): string[] { + return this.sys.getDirectories(path); + } + + public readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] { + return this.sys.readDirectory(path, extensions, exclude, include, depth); + } + + public readFile(path: string): string | undefined { + return this.sys.readFile(path); + } + + public writeFile(fileName: string, content: string, writeByteOrderMark: boolean) { + if (writeByteOrderMark) content = Utils.addUTF8ByteOrderMark(content); + this.sys.writeFile(fileName, content); + + const document = new documents.TextDocument(fileName, content); + document.meta.set("fileName", fileName); + this.vfs.filemeta(fileName).set("document", document); + if (!this._outputsMap.has(document.file)) { + this._outputsMap.set(document.file, this.outputs.length); + this.outputs.push(document); + } + this.outputs[this._outputsMap.get(document.file)!] = document; + } + + public trace(s: string): void { + this.traces.push(s); + } + + public realpath(path: string): string { + return this.sys.realpath(path); + } + + public getDefaultLibLocation(): string { + return vpath.resolve(this.getCurrentDirectory(), this.defaultLibLocation); + } + + public getDefaultLibFileName(options: ts.CompilerOptions): string { + return vpath.resolve(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options)); + } + + public getSourceFile(fileName: string, languageVersion: number): ts.SourceFile | undefined { + const canonicalFileName = this.getCanonicalFileName(vpath.resolve(this.getCurrentDirectory(), fileName)); + const existing = this._sourceFiles.get(canonicalFileName); + if (existing) return existing; + + const content = this.readFile(canonicalFileName); + if (content === undefined) return undefined; + + // A virtual file system may shadow another existing virtual file system. This + // allows us to reuse a common virtual file system structure across multiple + // tests. If a virtual file is a shadow, it is likely that the file will be + // reused across multiple tests. In that case, we cache the SourceFile we parse + // so that it can be reused across multiple tests to avoid the cost of + // repeatedly parsing the same file over and over (such as lib.d.ts). + const cacheKey = this.vfs.shadowRoot && `SourceFile[languageVersion=${languageVersion},setParentNodes=${this._setParentNodes}]`; + if (cacheKey) { + const meta = this.vfs.filemeta(canonicalFileName); + const sourceFileFromMetadata = meta.get(cacheKey) as ts.SourceFile | undefined; + if (sourceFileFromMetadata && sourceFileFromMetadata.getFullText() === content) { + this._sourceFiles.set(canonicalFileName, sourceFileFromMetadata); + return sourceFileFromMetadata; + } + } + + const parsed = ts.createSourceFile(fileName, content, languageVersion, this._setParentNodes || this.shouldAssertInvariants); + + this._sourceFiles.set(canonicalFileName, parsed); + + if (cacheKey) { + // store the cached source file on the unshadowed file with the same version. + const stats = this.vfs.statSync(canonicalFileName); + + let fs = this.vfs; + while (fs.shadowRoot) { + try { + const shadowRootStats = fs.shadowRoot.existsSync(canonicalFileName) ? fs.shadowRoot.statSync(canonicalFileName) : undefined!; // TODO: GH#18217 + if (shadowRootStats.dev !== stats.dev || + shadowRootStats.ino !== stats.ino || + shadowRootStats.mtimeMs !== stats.mtimeMs) { + break; + } + + fs = fs.shadowRoot; + } + catch { + break; + } + } + + if (fs !== this.vfs) { + fs.filemeta(canonicalFileName).set(cacheKey, parsed); + } + } + + return parsed; + } +} +/** + * djb2 hashing algorithm + * http://www.cse.yorku.ca/~oz/hash.html + * + * @internal + */ + export function generateDjb2Hash(data: string): string { + let acc = 5381; + for (let i = 0; i < data.length; i++) { + acc = ((acc << 5) + acc) + data.charCodeAt(i); + } + return acc.toString(); +} diff --git a/external-declarations/src/test-runner/tsc-infrastructure/io.ts b/external-declarations/src/test-runner/tsc-infrastructure/io.ts new file mode 100644 index 0000000000000..ad4305913df3b --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/io.ts @@ -0,0 +1,177 @@ +import { sys } from "typescript"; +import { FileSystemEntries } from "./vfs"; +import * as vpath from './vpath'; +import { compareStringsCaseSensitive, compareStringsCaseInsensitive } from "../../compiler/lang-utils"; +type RunnerBase = unknown; + +export interface IO { + newLine(): string; + getCurrentDirectory(): string; + useCaseSensitiveFileNames(): boolean; + resolvePath(path: string): string | undefined; + getFileSize(path: string): number; + readFile(path: string): string | undefined; + writeFile(path: string, contents: string): void; + directoryName(path: string): string | undefined; + getDirectories(path: string): string[]; + createDirectory(path: string): void; + fileExists(fileName: string): boolean; + directoryExists(path: string): boolean; + deleteFile(fileName: string): void; + listFiles(path: string, filter?: RegExp, options?: { recursive?: boolean }): string[]; + log(text: string): void; + args(): string[]; + getExecutingFilePath(): string; + getWorkspaceRoot(): string; + exit(exitCode?: number): void; + readDirectory(path: string, extension?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): readonly string[]; + getAccessibleFileSystemEntries(dirname: string): FileSystemEntries; + tryEnableSourceMapsForHost?(): void; + getEnvironmentVariable?(name: string): string; + getMemoryUsage?(): number | undefined; + joinPath(...components: string[]): string +} + +export let IO: IO; +export function setHarnessIO(io: IO) { + IO = io; +} + +// harness always uses one kind of new line +// But note that `parseTestData` in `fourslash.ts` uses "\n" +export const harnessNewLine = "\r\n"; + +// Root for file paths that are stored in a virtual file system +export const virtualFileSystemRoot = "/"; + +function createNodeIO(): IO { + let workspaceRoot = "../"; + let fs: any, pathModule: any; + if (require) { + fs = require("fs"); + pathModule = require("path"); + workspaceRoot = pathModule.resolve(workspaceRoot); + } + else { + fs = pathModule = {}; + } + + function deleteFile(path: string) { + try { + fs.unlinkSync(path); + } + catch { /*ignore*/ } + } + + function directoryName(path: string) { + const dirPath = pathModule.dirname(path); + // Node will just continue to repeat the root path, rather than return null + return dirPath === path ? undefined : dirPath; + } + + function joinPath(...components: string[]) { + return pathModule.join(...components); + } + + function enumerateTestFiles(runner: RunnerBase):any[] { + throw new Error("Not implemented"); + // return runner.getTestFiles(); + } + + function listFiles(path: string, spec: RegExp, options: { recursive?: boolean } = {}) { + function filesInFolder(folder: string): string[] { + let paths: string[] = []; + + for (const file of fs.readdirSync(folder)) { + const pathToFile = pathModule.join(folder, file); + if (!fs.existsSync(pathToFile)) continue; // ignore invalid symlinks + const stat = fs.statSync(pathToFile); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(pathToFile)); + } + else if (stat.isFile() && (!spec || file.match(spec))) { + paths.push(pathToFile); + } + } + + return paths; + } + + return filesInFolder(path); + } + + function getAccessibleFileSystemEntries(dirname: string): FileSystemEntries { + try { + const entries: string[] = fs.readdirSync(dirname || ".").sort(sys.useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive); + const files: string[] = []; + const directories: string[] = []; + for (const entry of entries) { + if (entry === "." || entry === "..") continue; + const name = vpath.combine(dirname, entry); + try { + const stat = fs.statSync(name); + if (!stat) continue; + if (stat.isFile()) { + files.push(entry); + } + else if (stat.isDirectory()) { + directories.push(entry); + } + } + catch { /*ignore*/ } + } + return { files, directories }; + } + catch (e) { + return { files: [], directories: [] }; + } + } + + function createDirectory(path: string) { + try { + fs.mkdirSync(path); + } + catch (e) { + if (e.code === "ENOENT") { + createDirectory(vpath.dirname(path)); + createDirectory(path); + } + else if (!sys.directoryExists(path)) { + throw e; + } + } + } + + return { + newLine: () => harnessNewLine, + getCurrentDirectory: () => sys.getCurrentDirectory(), + useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames, + resolvePath: (path: string) => sys.resolvePath(path), + getFileSize: (path: string) => sys.getFileSize!(path), + readFile: path => sys.readFile(path), + writeFile: (path, content) => sys.writeFile(path, content), + directoryName, + getDirectories: path => sys.getDirectories(path), + createDirectory, + fileExists: path => sys.fileExists(path), + directoryExists: path => sys.directoryExists(path), + deleteFile, + listFiles, + log: s => console.log(s), + args: () => sys.args, + getExecutingFilePath: () => sys.getExecutingFilePath(), + getWorkspaceRoot: () => workspaceRoot, + exit: exitCode => sys.exit(exitCode), + readDirectory: (path, extension, exclude, include, depth) => sys.readDirectory(path, extension, exclude, include, depth), + getAccessibleFileSystemEntries, + tryEnableSourceMapsForHost: () => { throw new Error("Not supported")}, + getMemoryUsage: () => sys.getMemoryUsage && sys.getMemoryUsage(), + getEnvironmentVariable(name: string) { + return process.env[name] || ""; + }, + joinPath + }; +} + + +IO = createNodeIO(); diff --git a/external-declarations/src/test-runner/tsc-infrastructure/options.ts b/external-declarations/src/test-runner/tsc-infrastructure/options.ts new file mode 100644 index 0000000000000..ac036e0057acc --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/options.ts @@ -0,0 +1,1477 @@ + +// Watch related options + +import { WatchFileKind, WatchDirectoryKind, PollingWatchKind, ScriptTarget, ModuleKind, ImportsNotUsedAsValues, ModuleResolutionKind, NewLineKind, ModuleDetectionKind, JsxEmit, DiagnosticMessage, CompilerOptionsValue, Diagnostic } from "typescript"; +import { isNullOrUndefined } from "../../compiler/lang-utils"; +import { Diagnostics } from "../../compiler/diagnosticInformationMap.generated"; +import { getEntries, mapDefined, startsWith, trimString } from "../../compiler/lang-utils"; + +const jsxOptionMap = new Map(getEntries({ + "preserve": JsxEmit.Preserve, + "react-native": JsxEmit.ReactNative, + "react": JsxEmit.React, + "react-jsx": JsxEmit.ReactJSX, + "react-jsxdev": JsxEmit.ReactJSXDev, +})); + + +// NOTE: The order here is important to default lib ordering as entries will have the same +// order in the generated program (see `getDefaultLibPriority` in program.ts). This +// order also affects overload resolution when a type declared in one lib is +// augmented in another lib. +const libEntries: [string, string][] = [ + // JavaScript only + ["es5", "lib.es5.d.ts"], + ["es6", "lib.es2015.d.ts"], + ["es2015", "lib.es2015.d.ts"], + ["es7", "lib.es2016.d.ts"], + ["es2016", "lib.es2016.d.ts"], + ["es2017", "lib.es2017.d.ts"], + ["es2018", "lib.es2018.d.ts"], + ["es2019", "lib.es2019.d.ts"], + ["es2020", "lib.es2020.d.ts"], + ["es2021", "lib.es2021.d.ts"], + ["es2022", "lib.es2022.d.ts"], + ["esnext", "lib.esnext.d.ts"], + // Host only + ["dom", "lib.dom.d.ts"], + ["dom.iterable", "lib.dom.iterable.d.ts"], + ["webworker", "lib.webworker.d.ts"], + ["webworker.importscripts", "lib.webworker.importscripts.d.ts"], + ["webworker.iterable", "lib.webworker.iterable.d.ts"], + ["scripthost", "lib.scripthost.d.ts"], + // ES2015 Or ESNext By-feature options + ["es2015.core", "lib.es2015.core.d.ts"], + ["es2015.collection", "lib.es2015.collection.d.ts"], + ["es2015.generator", "lib.es2015.generator.d.ts"], + ["es2015.iterable", "lib.es2015.iterable.d.ts"], + ["es2015.promise", "lib.es2015.promise.d.ts"], + ["es2015.proxy", "lib.es2015.proxy.d.ts"], + ["es2015.reflect", "lib.es2015.reflect.d.ts"], + ["es2015.symbol", "lib.es2015.symbol.d.ts"], + ["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"], + ["es2016.array.include", "lib.es2016.array.include.d.ts"], + ["es2017.object", "lib.es2017.object.d.ts"], + ["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"], + ["es2017.string", "lib.es2017.string.d.ts"], + ["es2017.intl", "lib.es2017.intl.d.ts"], + ["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"], + ["es2018.asyncgenerator", "lib.es2018.asyncgenerator.d.ts"], + ["es2018.asynciterable", "lib.es2018.asynciterable.d.ts"], + ["es2018.intl", "lib.es2018.intl.d.ts"], + ["es2018.promise", "lib.es2018.promise.d.ts"], + ["es2018.regexp", "lib.es2018.regexp.d.ts"], + ["es2019.array", "lib.es2019.array.d.ts"], + ["es2019.object", "lib.es2019.object.d.ts"], + ["es2019.string", "lib.es2019.string.d.ts"], + ["es2019.symbol", "lib.es2019.symbol.d.ts"], + ["es2019.intl", "lib.es2019.intl.d.ts"], + ["es2020.bigint", "lib.es2020.bigint.d.ts"], + ["es2020.date", "lib.es2020.date.d.ts"], + ["es2020.promise", "lib.es2020.promise.d.ts"], + ["es2020.sharedmemory", "lib.es2020.sharedmemory.d.ts"], + ["es2020.string", "lib.es2020.string.d.ts"], + ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], + ["es2020.intl", "lib.es2020.intl.d.ts"], + ["es2020.number", "lib.es2020.number.d.ts"], + ["es2021.promise", "lib.es2021.promise.d.ts"], + ["es2021.string", "lib.es2021.string.d.ts"], + ["es2021.weakref", "lib.es2021.weakref.d.ts"], + ["es2021.intl", "lib.es2021.intl.d.ts"], + ["es2022.array", "lib.es2022.array.d.ts"], + ["es2022.error", "lib.es2022.error.d.ts"], + ["es2022.intl", "lib.es2022.intl.d.ts"], + ["es2022.object", "lib.es2022.object.d.ts"], + ["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"], + ["es2022.string", "lib.es2022.string.d.ts"], + ["esnext.array", "lib.es2022.array.d.ts"], + ["esnext.symbol", "lib.es2019.symbol.d.ts"], + ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"], + ["esnext.bigint", "lib.es2020.bigint.d.ts"], + ["esnext.string", "lib.es2022.string.d.ts"], + ["esnext.promise", "lib.es2021.promise.d.ts"], + ["esnext.weakref", "lib.es2021.weakref.d.ts"] +]; + +/** + * An array of supported "lib" reference file names used to determine the order for inclusion + * when referenced, as well as for spelling suggestions. This ensures the correct ordering for + * overload resolution when a type declared in one lib is extended by another. + * + * @internal + */ +export const libs = libEntries.map(entry => entry[0]); + +/** + * A map of lib names to lib files. This map is used both for parsing the "lib" command line + * option as well as for resolving lib reference directives. + * + * @internal + */ +export const libMap = new Map(libEntries); + + +/** @internal */ +export const optionsForWatch = [ + { + name: "watchFile", + type: new Map(getEntries({ + fixedpollinginterval: WatchFileKind.FixedPollingInterval, + prioritypollinginterval: WatchFileKind.PriorityPollingInterval, + dynamicprioritypolling: WatchFileKind.DynamicPriorityPolling, + fixedchunksizepolling: WatchFileKind.FixedChunkSizePolling, + usefsevents: WatchFileKind.UseFsEvents, + usefseventsonparentdirectory: WatchFileKind.UseFsEventsOnParentDirectory, + })), + category: Diagnostics.Watch_and_Build_Modes, + description: Diagnostics.Specify_how_the_TypeScript_watch_mode_works, + defaultValueDescription: WatchFileKind.UseFsEvents, + }, + { + name: "watchDirectory", + type: new Map(getEntries({ + usefsevents: WatchDirectoryKind.UseFsEvents, + fixedpollinginterval: WatchDirectoryKind.FixedPollingInterval, + dynamicprioritypolling: WatchDirectoryKind.DynamicPriorityPolling, + fixedchunksizepolling: WatchDirectoryKind.FixedChunkSizePolling, + })), + category: Diagnostics.Watch_and_Build_Modes, + description: Diagnostics.Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality, + defaultValueDescription: WatchDirectoryKind.UseFsEvents, + }, + { + name: "fallbackPolling", + type: new Map(getEntries({ + fixedinterval: PollingWatchKind.FixedInterval, + priorityinterval: PollingWatchKind.PriorityInterval, + dynamicpriority: PollingWatchKind.DynamicPriority, + fixedchunksize: PollingWatchKind.FixedChunkSize, + })), + category: Diagnostics.Watch_and_Build_Modes, + description: Diagnostics.Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers, + defaultValueDescription: PollingWatchKind.PriorityInterval, + }, + { + name: "synchronousWatchDirectory", + type: "boolean", + category: Diagnostics.Watch_and_Build_Modes, + description: Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, + defaultValueDescription: false, + }, + { + name: "excludeDirectories", + type: "list", + element: { + name: "excludeDirectory", + type: "string", + isFilePath: true, + }, + category: Diagnostics.Watch_and_Build_Modes, + description: Diagnostics.Remove_a_list_of_directories_from_the_watch_process, + }, + { + name: "excludeFiles", + type: "list", + element: { + name: "excludeFile", + type: "string", + isFilePath: true, + }, + category: Diagnostics.Watch_and_Build_Modes, + description: Diagnostics.Remove_a_list_of_files_from_the_watch_mode_s_processing, + }, +]; + +/** @internal */ +export const commonOptionsWithBuild = [ + { + name: "help", + shortName: "h", + type: "boolean", + showInSimplifiedHelpView: true, + isCommandLineOnly: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Print_this_message, + defaultValueDescription: false, + }, + { + name: "help", + shortName: "?", + type: "boolean", + isCommandLineOnly: true, + category: Diagnostics.Command_line_Options, + defaultValueDescription: false, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + showInSimplifiedHelpView: true, + isCommandLineOnly: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Watch_input_files, + defaultValueDescription: false, + }, + { + name: "preserveWatchOutput", + type: "boolean", + showInSimplifiedHelpView: false, + category: Diagnostics.Output_Formatting, + description: Diagnostics.Disable_wiping_the_console_in_watch_mode, + defaultValueDescription: false, + }, + { + name: "listFiles", + type: "boolean", + category: Diagnostics.Compiler_Diagnostics, + description: Diagnostics.Print_all_of_the_files_read_during_the_compilation, + defaultValueDescription: false, + }, + { + name: "explainFiles", + type: "boolean", + category: Diagnostics.Compiler_Diagnostics, + description: Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included, + defaultValueDescription: false, + }, + { + name: "listEmittedFiles", + type: "boolean", + category: Diagnostics.Compiler_Diagnostics, + description: Diagnostics.Print_the_names_of_emitted_files_after_a_compilation, + defaultValueDescription: false, + }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Output_Formatting, + description: Diagnostics.Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read, + defaultValueDescription: true, + }, + { + name: "traceResolution", + type: "boolean", + category: Diagnostics.Compiler_Diagnostics, + description: Diagnostics.Log_paths_used_during_the_moduleResolution_process, + defaultValueDescription: false, + }, + { + name: "diagnostics", + type: "boolean", + category: Diagnostics.Compiler_Diagnostics, + description: Diagnostics.Output_compiler_performance_information_after_building, + defaultValueDescription: false, + }, + { + name: "extendedDiagnostics", + type: "boolean", + category: Diagnostics.Compiler_Diagnostics, + description: Diagnostics.Output_more_detailed_compiler_performance_information_after_building, + defaultValueDescription: false, + }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: Diagnostics.FILE_OR_DIRECTORY, + category: Diagnostics.Compiler_Diagnostics, + description: Diagnostics.Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging, + defaultValueDescription: "profile.cpuprofile" + }, + { + name: "generateTrace", + type: "string", + isFilePath: true, + isCommandLineOnly: true, + paramType: Diagnostics.DIRECTORY, + category: Diagnostics.Compiler_Diagnostics, + description: Diagnostics.Generates_an_event_trace_and_a_list_of_types + }, + { + name: "incremental", + shortName: "i", + type: "boolean", + category: Diagnostics.Projects, + description: Diagnostics.Save_tsbuildinfo_files_to_allow_for_incremental_compilation_of_projects, + transpileOptionValue: undefined, + defaultValueDescription: Diagnostics.false_unless_composite_is_set + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + // Not setting affectsEmit because we calculate this flag might not affect full emit + affectsBuildInfo: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Emit, + transpileOptionValue: undefined, + description: Diagnostics.Generate_d_ts_files_from_TypeScript_and_JavaScript_files_in_your_project, + defaultValueDescription: Diagnostics.false_unless_composite_is_set, + }, + { + name: "declarationMap", + type: "boolean", + // Not setting affectsEmit because we calculate this flag might not affect full emit + affectsBuildInfo: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Emit, + transpileOptionValue: undefined, + defaultValueDescription: false, + description: Diagnostics.Create_sourcemaps_for_d_ts_files + }, + { + name: "emitDeclarationOnly", + type: "boolean", + // Not setting affectsEmit because we calculate this flag might not affect full emit + affectsBuildInfo: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Emit, + description: Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files, + transpileOptionValue: undefined, + defaultValueDescription: false, + }, + { + name: "sourceMap", + type: "boolean", + // Not setting affectsEmit because we calculate this flag might not affect full emit + affectsBuildInfo: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Emit, + defaultValueDescription: false, + description: Diagnostics.Create_source_map_files_for_emitted_JavaScript_files, + }, + { + name: "inlineSourceMap", + type: "boolean", + // Not setting affectsEmit because we calculate this flag might not affect full emit + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript, + defaultValueDescription: false, + }, + { + name: "assumeChangesOnlyAffectDirectDependencies", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Watch_and_Build_Modes, + description: Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it, + defaultValueDescription: false, + }, + { + name: "locale", + type: "string", + category: Diagnostics.Command_line_Options, + isCommandLineOnly: true, + description: Diagnostics.Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit, + defaultValueDescription: Diagnostics.Platform_specific + }, +] as const; + +/** @internal */ +export const targetOptionDeclaration = { + name: "target", + shortName: "t", + type: new Map(getEntries({ + es3: ScriptTarget.ES3, + es5: ScriptTarget.ES5, + es6: ScriptTarget.ES2015, + es2015: ScriptTarget.ES2015, + es2016: ScriptTarget.ES2016, + es2017: ScriptTarget.ES2017, + es2018: ScriptTarget.ES2018, + es2019: ScriptTarget.ES2019, + es2020: ScriptTarget.ES2020, + es2021: ScriptTarget.ES2021, + es2022: ScriptTarget.ES2022, + esnext: ScriptTarget.ESNext, + })), + affectsSourceFile: true, + affectsModuleResolution: true, + affectsEmit: true, + affectsBuildInfo: true, + paramType: Diagnostics.VERSION, + showInSimplifiedHelpView: true, + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, + defaultValueDescription: ScriptTarget.ES3, +} as const; + +/** @internal */ +export const moduleOptionDeclaration = { + name: "module", + shortName: "m", + type: new Map(getEntries({ + none: ModuleKind.None, + commonjs: ModuleKind.CommonJS, + amd: ModuleKind.AMD, + system: ModuleKind.System, + umd: ModuleKind.UMD, + es6: ModuleKind.ES2015, + es2015: ModuleKind.ES2015, + es2020: ModuleKind.ES2020, + es2022: ModuleKind.ES2022, + esnext: ModuleKind.ESNext, + node16: ModuleKind.Node16, + nodenext: ModuleKind.NodeNext, + })), + affectsModuleResolution: true, + affectsEmit: true, + affectsBuildInfo: true, + paramType: Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: Diagnostics.Modules, + description: Diagnostics.Specify_what_module_code_is_generated, + defaultValueDescription: undefined, +} as const; + +const commandOptionsWithoutBuild = [ + // CommandLine only options + { + name: "all", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Show_all_compiler_options, + defaultValueDescription: false, + }, + { + name: "version", + shortName: "v", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Print_the_compiler_s_version, + defaultValueDescription: false, + }, + { + name: "init", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + defaultValueDescription: false, + }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + paramType: Diagnostics.FILE_OR_DIRECTORY, + description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + }, + { + name: "build", + type: "boolean", + shortName: "b", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date, + defaultValueDescription: false, + }, + { + name: "showConfig", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + isCommandLineOnly: true, + description: Diagnostics.Print_the_final_configuration_instead_of_building, + defaultValueDescription: false, + }, + { + name: "listFilesOnly", + type: "boolean", + category: Diagnostics.Command_line_Options, + isCommandLineOnly: true, + description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing, + defaultValueDescription: false, + }, + + // Basic + targetOptionDeclaration, + moduleOptionDeclaration, + { + name: "lib", + type: "list", + element: { + name: "lib", + type: libMap, + defaultValueDescription: undefined, + }, + affectsProgramStructure: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment, + transpileOptionValue: undefined + }, + { + name: "allowJs", + type: "boolean", + affectsModuleResolution: true, + showInSimplifiedHelpView: true, + category: Diagnostics.JavaScript_Support, + description: Diagnostics.Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files, + defaultValueDescription: false, + }, + { + name: "checkJs", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.JavaScript_Support, + description: Diagnostics.Enable_error_reporting_in_type_checked_JavaScript_files, + defaultValueDescription: false, + }, + { + name: "jsx", + type: jsxOptionMap, + affectsSourceFile: true, + affectsEmit: true, + affectsBuildInfo: true, + affectsModuleResolution: true, + paramType: Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Specify_what_JSX_code_is_generated, + defaultValueDescription: undefined, + }, + { + name: "outFile", + type: "string", + affectsEmit: true, + affectsBuildInfo: true, + affectsDeclarationPath: true, + isFilePath: true, + paramType: Diagnostics.FILE, + showInSimplifiedHelpView: true, + category: Diagnostics.Emit, + description: Diagnostics.Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output, + transpileOptionValue: undefined, + }, + { + name: "outDir", + type: "string", + affectsEmit: true, + affectsBuildInfo: true, + affectsDeclarationPath: true, + isFilePath: true, + paramType: Diagnostics.DIRECTORY, + showInSimplifiedHelpView: true, + category: Diagnostics.Emit, + description: Diagnostics.Specify_an_output_folder_for_all_emitted_files, + }, + { + name: "rootDir", + type: "string", + affectsEmit: true, + affectsBuildInfo: true, + affectsDeclarationPath: true, + isFilePath: true, + paramType: Diagnostics.LOCATION, + category: Diagnostics.Modules, + description: Diagnostics.Specify_the_root_folder_within_your_source_files, + defaultValueDescription: Diagnostics.Computed_from_the_list_of_input_files + }, + { + name: "composite", + type: "boolean", + // Not setting affectsEmit because we calculate this flag might not affect full emit + affectsBuildInfo: true, + isTSConfigOnly: true, + category: Diagnostics.Projects, + transpileOptionValue: undefined, + defaultValueDescription: false, + description: Diagnostics.Enable_constraints_that_allow_a_TypeScript_project_to_be_used_with_project_references, + }, + { + name: "tsBuildInfoFile", + type: "string", + affectsEmit: true, + affectsBuildInfo: true, + isFilePath: true, + paramType: Diagnostics.FILE, + category: Diagnostics.Projects, + transpileOptionValue: undefined, + defaultValueDescription: ".tsbuildinfo", + description: Diagnostics.Specify_the_path_to_tsbuildinfo_incremental_compilation_file, + }, + { + name: "removeComments", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Emit, + defaultValueDescription: false, + description: Diagnostics.Disable_emitting_comments, + }, + { + name: "noEmit", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Emit, + description: Diagnostics.Disable_emitting_files_from_a_compilation, + transpileOptionValue: undefined, + defaultValueDescription: false, + }, + { + name: "importHelpers", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file, + defaultValueDescription: false, + }, + { + name: "importsNotUsedAsValues", + type: new Map(getEntries({ + remove: ImportsNotUsedAsValues.Remove, + preserve: ImportsNotUsedAsValues.Preserve, + error: ImportsNotUsedAsValues.Error, + })), + affectsEmit: true, + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, + defaultValueDescription: ImportsNotUsedAsValues.Remove, + }, + { + name: "downlevelIteration", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration, + defaultValueDescription: false, + }, + { + name: "isolatedModules", + type: "boolean", + category: Diagnostics.Interop_Constraints, + description: Diagnostics.Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports, + transpileOptionValue: true, + defaultValueDescription: false, + }, + { + name: "isolatedDeclarations", + type: "boolean", + category: Diagnostics.Interop_Constraints, + description: Diagnostics.Ensure_that_each_file_can_have_declaration_emit_generated_without_type_information, + transpileOptionValue: true, + defaultValueDescription: false, + }, + + // Strict Type Checks + { + name: "strict", + type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. + // But we need to store `strict` in builf info, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly + affectsBuildInfo: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Enable_all_strict_type_checking_options, + defaultValueDescription: false, + }, + { + name: "noImplicitAny", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + strictFlag: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type, + defaultValueDescription: Diagnostics.false_unless_strict_is_set + }, + { + name: "strictNullChecks", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + strictFlag: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.When_type_checking_take_into_account_null_and_undefined, + defaultValueDescription: Diagnostics.false_unless_strict_is_set + }, + { + name: "strictFunctionTypes", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + strictFlag: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible, + defaultValueDescription: Diagnostics.false_unless_strict_is_set + }, + { + name: "strictBindCallApply", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + strictFlag: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function, + defaultValueDescription: Diagnostics.false_unless_strict_is_set + }, + { + name: "strictPropertyInitialization", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + strictFlag: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor, + defaultValueDescription: Diagnostics.false_unless_strict_is_set + }, + { + name: "noImplicitThis", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + strictFlag: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any, + defaultValueDescription: Diagnostics.false_unless_strict_is_set + }, + { + name: "useUnknownInCatchVariables", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + strictFlag: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any, + defaultValueDescription: false, + }, + { + name: "alwaysStrict", + type: "boolean", + affectsSourceFile: true, + affectsEmit: true, + affectsBuildInfo: true, + strictFlag: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Ensure_use_strict_is_always_emitted, + defaultValueDescription: Diagnostics.false_unless_strict_is_set + }, + + // Additional Checks + { + name: "noUnusedLocals", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read, + defaultValueDescription: false, + }, + { + name: "noUnusedParameters", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read, + defaultValueDescription: false, + }, + { + name: "exactOptionalPropertyTypes", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined, + defaultValueDescription: false, + }, + { + name: "noImplicitReturns", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function, + defaultValueDescription: false, + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + affectsBindDiagnostics: true, + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements, + defaultValueDescription: false, + }, + { + name: "noUncheckedIndexedAccess", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index, + defaultValueDescription: false, + }, + { + name: "noImplicitOverride", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier, + defaultValueDescription: false, + }, + { + name: "noPropertyAccessFromIndexSignature", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + showInSimplifiedHelpView: false, + category: Diagnostics.Type_Checking, + description: Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type, + defaultValueDescription: false, + }, + + // Module Resolution + { + name: "moduleResolution", + type: new Map(getEntries({ + node: ModuleResolutionKind.NodeJs, + classic: ModuleResolutionKind.Classic, + node16: ModuleResolutionKind.Node16, + nodenext: ModuleResolutionKind.NodeNext, + })), + affectsModuleResolution: true, + paramType: Diagnostics.STRATEGY, + category: Diagnostics.Modules, + description: Diagnostics.Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier, + defaultValueDescription: Diagnostics.module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node + }, + { + name: "baseUrl", + type: "string", + affectsModuleResolution: true, + isFilePath: true, + category: Diagnostics.Modules, + description: Diagnostics.Specify_the_base_directory_to_resolve_non_relative_module_names + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "paths", + type: "object", + affectsModuleResolution: true, + isTSConfigOnly: true, + category: Diagnostics.Modules, + description: Diagnostics.Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations, + transpileOptionValue: undefined + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + }, + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules, + transpileOptionValue: undefined, + defaultValueDescription: Diagnostics.Computed_from_the_list_of_input_files + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + }, + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + affectsProgramStructure: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Modules, + description: Diagnostics.Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file, + transpileOptionValue: undefined + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Interop_Constraints, + description: Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export, + defaultValueDescription: Diagnostics.module_system_or_esModuleInterop + }, + { + name: "esModuleInterop", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsEmit: true, + affectsBuildInfo: true, + showInSimplifiedHelpView: true, + category: Diagnostics.Interop_Constraints, + description: Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility, + defaultValueDescription: false, + }, + { + name: "preserveSymlinks", + type: "boolean", + category: Diagnostics.Interop_Constraints, + description: Diagnostics.Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node, + defaultValueDescription: false, + }, + { + name: "allowUmdGlobalAccess", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Modules, + description: Diagnostics.Allow_accessing_UMD_globals_from_modules, + defaultValueDescription: false, + }, + { + name: "moduleSuffixes", + type: "list", + element: { + name: "suffix", + type: "string", + }, + listPreserveFalsyValues: true, + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module, + }, + + // Source Maps + { + name: "sourceRoot", + type: "string", + affectsEmit: true, + affectsBuildInfo: true, + paramType: Diagnostics.LOCATION, + category: Diagnostics.Emit, + description: Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code, + }, + { + name: "mapRoot", + type: "string", + affectsEmit: true, + affectsBuildInfo: true, + paramType: Diagnostics.LOCATION, + category: Diagnostics.Emit, + description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + }, + { + name: "inlineSources", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript, + defaultValueDescription: false, + }, + + // Experimental + { + name: "experimentalDecorators", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators, + defaultValueDescription: false, + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files, + defaultValueDescription: false, + }, + + // Advanced + { + name: "jsxFactory", + type: "string", + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h, + defaultValueDescription: "`React.createElement`" + }, + { + name: "jsxFragmentFactory", + type: "string", + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment, + defaultValueDescription: "React.Fragment", + }, + { + name: "jsxImportSource", + type: "string", + affectsSemanticDiagnostics: true, + affectsEmit: true, + affectsBuildInfo: true, + affectsModuleResolution: true, + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk, + defaultValueDescription: "react" + }, + { + name: "resolveJsonModule", + type: "boolean", + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Enable_importing_json_files, + defaultValueDescription: false, + }, + + { + name: "out", + type: "string", + affectsEmit: true, + affectsBuildInfo: true, + affectsDeclarationPath: true, + isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files + // for correct behaviour, please use outFile + category: Diagnostics.Backwards_Compatibility, + paramType: Diagnostics.FILE, + transpileOptionValue: undefined, + description: Diagnostics.Deprecated_setting_Use_outFile_instead, + }, + { + name: "reactNamespace", + type: "string", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit, + defaultValueDescription: "`React`", + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + // We need to store these to determine whether `lib` files need to be rechecked + affectsBuildInfo: true, + category: Diagnostics.Completeness, + description: Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript, + defaultValueDescription: false, + }, + { + name: "charset", + type: "string", + category: Diagnostics.Backwards_Compatibility, + description: Diagnostics.No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files, + defaultValueDescription: "utf8" + }, + { + name: "emitBOM", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files, + defaultValueDescription: false, + }, + { + name: "newLine", + type: new Map(getEntries({ + crlf: NewLineKind.CarriageReturnLineFeed, + lf: NewLineKind.LineFeed + })), + affectsEmit: true, + affectsBuildInfo: true, + paramType: Diagnostics.NEWLINE, + category: Diagnostics.Emit, + description: Diagnostics.Set_the_newline_character_for_emitting_files, + defaultValueDescription: Diagnostics.Platform_specific + }, + { + name: "noErrorTruncation", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Output_Formatting, + description: Diagnostics.Disable_truncating_types_in_error_messages, + defaultValueDescription: false, + }, + { + name: "noLib", + type: "boolean", + category: Diagnostics.Language_and_Environment, + affectsProgramStructure: true, + description: Diagnostics.Disable_including_any_library_files_including_the_default_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true, + defaultValueDescription: false, + }, + { + name: "noResolve", + type: "boolean", + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add_to_a_project, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true, + defaultValueDescription: false, + }, + { + name: "stripInternal", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments, + defaultValueDescription: false, + }, + { + name: "disableSizeLimit", + type: "boolean", + affectsProgramStructure: true, + category: Diagnostics.Editor_Support, + description: Diagnostics.Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server, + defaultValueDescription: false, + }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + isTSConfigOnly: true, + category: Diagnostics.Projects, + description: Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects, + defaultValueDescription: false, + }, + { + name: "disableSolutionSearching", + type: "boolean", + isTSConfigOnly: true, + category: Diagnostics.Projects, + description: Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing, + defaultValueDescription: false, + }, + { + name: "disableReferencedProjectLoad", + type: "boolean", + isTSConfigOnly: true, + category: Diagnostics.Projects, + description: Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript, + defaultValueDescription: false, + }, + { + name: "noImplicitUseStrict", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Backwards_Compatibility, + description: Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files, + defaultValueDescription: false, + }, + { + name: "noEmitHelpers", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output, + defaultValueDescription: false, + }, + { + name: "noEmitOnError", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + transpileOptionValue: undefined, + description: Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported, + defaultValueDescription: false, + }, + { + name: "preserveConstEnums", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code, + defaultValueDescription: false, + }, + { + name: "declarationDir", + type: "string", + affectsEmit: true, + affectsBuildInfo: true, + affectsDeclarationPath: true, + isFilePath: true, + paramType: Diagnostics.DIRECTORY, + category: Diagnostics.Emit, + transpileOptionValue: undefined, + description: Diagnostics.Specify_the_output_directory_for_generated_declaration_files, + }, + { + name: "skipLibCheck", + type: "boolean", + // We need to store these to determine whether `lib` files need to be rechecked + affectsBuildInfo: true, + category: Diagnostics.Completeness, + description: Diagnostics.Skip_type_checking_all_d_ts_files, + defaultValueDescription: false, + }, + { + name: "allowUnusedLabels", + type: "boolean", + affectsBindDiagnostics: true, + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Disable_error_reporting_for_unused_labels, + defaultValueDescription: undefined, + }, + { + name: "allowUnreachableCode", + type: "boolean", + affectsBindDiagnostics: true, + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Type_Checking, + description: Diagnostics.Disable_error_reporting_for_unreachable_code, + defaultValueDescription: undefined, + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Backwards_Compatibility, + description: Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals, + defaultValueDescription: false, + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Backwards_Compatibility, + description: Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures, + defaultValueDescription: false, + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + affectsModuleResolution: true, + category: Diagnostics.Interop_Constraints, + description: Diagnostics.Ensure_that_casing_is_correct_in_imports, + defaultValueDescription: false, + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + affectsModuleResolution: true, + category: Diagnostics.JavaScript_Support, + description: Diagnostics.Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicable_with_allowJs, + defaultValueDescription: 0, + }, + { + name: "noStrictGenericChecks", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Backwards_Compatibility, + description: Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, + defaultValueDescription: false, + }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Language_and_Environment, + description: Diagnostics.Emit_ECMAScript_standard_compliant_class_fields, + defaultValueDescription: Diagnostics.true_for_ES2022_and_above_including_ESNext + }, + { + name: "preserveValueImports", + type: "boolean", + affectsEmit: true, + affectsBuildInfo: true, + category: Diagnostics.Emit, + description: Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed, + defaultValueDescription: false, + }, + + { + name: "keyofStringsOnly", + type: "boolean", + category: Diagnostics.Backwards_Compatibility, + description: Diagnostics.Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option, + defaultValueDescription: false, + }, + { + // A list of plugins to load in the language service + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + }, + description: Diagnostics.Specify_a_list_of_language_service_plugins_to_include, + category: Diagnostics.Editor_Support, + + }, + { + name: "moduleDetection", + type: new Map(getEntries({ + auto: ModuleDetectionKind.Auto, + legacy: ModuleDetectionKind.Legacy, + force: ModuleDetectionKind.Force, + })), + affectsModuleResolution: true, + description: Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files, + category: Diagnostics.Language_and_Environment, + defaultValueDescription: Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules, + } +] as const; + +/** @internal */ +export const optionDeclarations = [ + ...commonOptionsWithBuild, + ...commandOptionsWithoutBuild, +]; + + +export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | TsConfigOnlyOption | CommandLineOptionOfListType; + + +/** @internal */ +export interface CommandLineOptionOfStringType extends CommandLineOptionBase { + type: "string"; + defaultValueDescription?: string | undefined | DiagnosticMessage; +} + +/** @internal */ +export interface CommandLineOptionOfNumberType extends CommandLineOptionBase { + type: "number"; + defaultValueDescription: number | undefined | DiagnosticMessage; +} + +/** @internal */ +export interface CommandLineOptionOfBooleanType extends CommandLineOptionBase { + type: "boolean"; + defaultValueDescription: boolean | undefined | DiagnosticMessage; +} + +/** @internal */ +export interface CommandLineOptionOfCustomType extends CommandLineOptionBase { + type: Map; // an object literal mapping named values to actual values + defaultValueDescription: number | string | undefined | DiagnosticMessage; +} + + +/** @internal */ +export interface TsConfigOnlyOption extends CommandLineOptionBase { + type: "object"; + elementOptions?: Map; +} + +/** @internal */ +export interface CommandLineOptionOfListType extends CommandLineOptionBase { + type: "list"; + element: CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | TsConfigOnlyOption; + listPreserveFalsyValues?: boolean; +} + + +/** @internal */ +export interface CommandLineOptionBase { + name: string; + type: "string" | "number" | "boolean" | "object" | "list" | Map; // a value of a primitive type, or an object literal mapping named values to actual values + isFilePath?: boolean; // True if option value is a path or fileName + shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' + description?: DiagnosticMessage; // The message describing what the command line switch does. + defaultValueDescription?: string | number | boolean | DiagnosticMessage; // The message describing what the dafault value is. string type is prepared for fixed chosen like "false" which do not need I18n. + paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter + isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file + isCommandLineOnly?: boolean; + showInSimplifiedHelpView?: boolean; + category?: DiagnosticMessage; + strictFlag?: true; // true if the option is one of the flag under strict + affectsSourceFile?: true; // true if we should recreate SourceFiles after this option changes + affectsModuleResolution?: true; // currently same effect as `affectsSourceFile` + affectsBindDiagnostics?: true; // true if this affects binding (currently same effect as `affectsSourceFile`) + affectsSemanticDiagnostics?: true; // true if option affects semantic diagnostics + affectsEmit?: true; // true if the options affects emit + affectsProgramStructure?: true; // true if program should be reconstructed from root files if option changes and does not affect module resolution as affectsModuleResolution indirectly means program needs to reconstructed + affectsDeclarationPath?: true; // true if the options affects declaration file path computed + affectsBuildInfo?: true; // true if this options should be emitted in buildInfo + transpileOptionValue?: boolean | undefined; // If set this means that the option should be set to this value when transpiling +} + + + +function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { + if (isNullOrUndefined(value)) return undefined; + const key = value.toLowerCase(); + const val = opt.type.get(key); + if (val !== undefined) { + return validateJsonOptionValue(opt, val, errors); + } + else { + return undefined; + } +} + + +function validateJsonOptionValue(opt: CommandLineOption, value: T, errors: Diagnostic[]): T | undefined { + if (isNullOrUndefined(value)) return undefined; + return value; +} + + +/** @internal */ +export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { + return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); +} + +/** @internal */ +export function parseListTypeOption(opt: CommandLineOptionOfListType, value = "", errors: Diagnostic[]): (string | number)[] | undefined { + value = trimString(value); + if (startsWith(value, "-")) { + return undefined; + } + if (value === "") { + return []; + } + const values = value.split(","); + switch (opt.element.type) { + case "number": + return mapDefined(values, v => validateJsonOptionValue(opt.element, parseInt(v), errors)); + case "string": + return mapDefined(values, v => validateJsonOptionValue(opt.element, v || "", errors)); + default: + return mapDefined(values, v => parseCustomTypeOption(opt.element as CommandLineOptionOfCustomType, v, errors)); + } +} diff --git a/external-declarations/src/test-runner/tsc-infrastructure/test-document.ts b/external-declarations/src/test-runner/tsc-infrastructure/test-document.ts new file mode 100644 index 0000000000000..70d5f7d154916 --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/test-document.ts @@ -0,0 +1,71 @@ +import { isLineBreak } from "typescript"; +import { CharacterCodes } from "../../compiler/types"; +import { TestFile } from "./compiler-run"; + + + +/** @internal */ +export function computeLineStarts(text: string): number[] { + const result: number[] = []; + let pos = 0; + let lineStart = 0; + while (pos < text.length) { + const ch = text.charCodeAt(pos); + pos++; + switch (ch) { + case CharacterCodes.carriageReturn: + if (text.charCodeAt(pos) === CharacterCodes.lineFeed) { + pos++; + } + // falls through + case CharacterCodes.lineFeed: + result.push(lineStart); + lineStart = pos; + break; + default: + if (ch > CharacterCodes.maxAsciiCharacter && isLineBreak(ch)) { + result.push(lineStart); + lineStart = pos; + } + break; + } + } + result.push(lineStart); + return result; +} + +export class TextDocument { + public readonly meta: Map; + public readonly file: string; + public readonly text: string; + + private _lineStarts: readonly number[] | undefined; + private _testFile: TestFile | undefined; + + constructor(file: string, text: string, meta?: Map) { + this.file = file; + this.text = text; + this.meta = meta || new Map(); + } + + public get lineStarts(): readonly number[] { + return this._lineStarts || (this._lineStarts = computeLineStarts(this.text)); + } + + public static fromTestFile(file: TestFile) { + return new TextDocument( + file.unitName, + file.content, + file.fileOptions && Object.keys(file.fileOptions) + .reduce((meta, key) => meta.set(key, file.fileOptions[key]), new Map())); + } + + public asTestFile() { + return this._testFile || (this._testFile = { + unitName: this.file, + content: this.text, + fileOptions: Array.from(this.meta) + .reduce((obj, [key, value]) => (obj[key] = value, obj), {} as Record) + }); + } +} \ No newline at end of file diff --git a/external-declarations/src/test-runner/tsc-infrastructure/test-file-parser.ts b/external-declarations/src/test-runner/tsc-infrastructure/test-file-parser.ts new file mode 100644 index 0000000000000..4c13887fadbb0 --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/test-file-parser.ts @@ -0,0 +1,216 @@ +import assert = require('assert'); +import * as ts from 'typescript' +import { find, forEach, orderedRemoveItemAt } from '../../compiler/lang-utils'; +import { getBaseFileName, getDirectoryPath, getNormalizedAbsolutePath, normalizePath } from '../../compiler/path-utils'; +import { _Path } from '../../compiler/types'; +import * as vfs from './vfs' + +/** all the necessary information to set the right compiler settings */ +export interface CompilerSettings { + [name: string]: string; +} +/** All the necessary information to turn a multi file test into useful units for later compilation */ +export interface TestUnitData { + content: string; + name: string; + fileOptions: any; + originalFilePath: string; + references: string[]; + startLine: number; + endLine: number; +} +export interface ParseConfigHost { + useCaseSensitiveFileNames: boolean; + + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; + + /** + * Gets a value indicating whether the specified path exists and is a file. + * @param path The path to test. + */ + fileExists(path: string): boolean; + + readFile(path: string): string | undefined; + trace?(s: string): void; +} + +const optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*([^\r\n]*)/gm; // multiple matches on multiple lines +const linkRegex = /^[\/]{2}\s*@link\s*:\s*([^\r\n]*)\s*->\s*([^\r\n]*)/gm; // multiple matches on multiple lines + +export function extractCompilerSettings(content: string): CompilerSettings { + const opts: CompilerSettings = {}; + + let match: RegExpExecArray | null; + while ((match = optionRegex.exec(content)) !== null) { // eslint-disable-line no-null/no-null + opts[match[1]] = match[2].trim(); + } + + return opts; +} + +/** Splits the given string on \r\n, or on only \n if that fails, or on only \r if *that* fails. */ +export function splitContentByNewlines(content: string) { + const split = (delimiter: string) => Object.assign(content.split(delimiter), { delimiter }); + // Split up the input file by line + // Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so + // we have to use string-based splitting instead and try to figure out the delimiting chars + let lines = split("\r\n"); + if (lines.length === 1) { + lines = split("\n"); + + if (lines.length === 1) { + lines = split("\r"); + } + } + return lines; +} + + +export function getConfigNameFromFileName(filename: string): "tsconfig.json" | "jsconfig.json" | undefined { + const flc = getBaseFileName(filename).toLowerCase(); + return find(["tsconfig.json" as const, "jsconfig.json" as const], x => x === flc); +} + + +export function parseSymlinkFromTest(line: string, symlinks: vfs.FileSet | undefined) { + const linkMetaData = linkRegex.exec(line); + linkRegex.lastIndex = 0; + if (!linkMetaData) return undefined; + + if (!symlinks) symlinks = {}; + symlinks[linkMetaData[2].trim()] = new vfs.Symlink(linkMetaData[1].trim()); + return symlinks; +} + + +export interface TestCaseContent { + settings: CompilerSettings; + testUnitData: TestUnitData[]; + tsConfig: ts.ParsedCommandLine | undefined; + tsConfigFileUnitData: TestUnitData | undefined; + symlinks?: vfs.FileSet; + code: string; +} + +/** Given a test file containing // @FileName directives, return an array of named units of code to be added to an existing compiler instance */ +export function makeUnitsFromTest(code: string, fileName: string, rootDir?: string, settings = extractCompilerSettings(code)): TestCaseContent { + // List of all the subfiles we've parsed out + const testUnitData: TestUnitData[] = []; + + const lines = splitContentByNewlines(code); + + // Stuff related to the subfile we're parsing + let currentFileContent: string | undefined; + let currentFileOptions: any = {}; + let currentFileName: any; + let currentFileStartLine: number = 0; + let currentFileEndLine: number = 0; + let refs: string[] = []; + let symlinks: vfs.FileSet | undefined; + let lineIndex = -1; + for (const line of lines) { + lineIndex++; + let testMetaData: RegExpExecArray | null; + const possiblySymlinks = parseSymlinkFromTest(line, symlinks); + if (possiblySymlinks) { + symlinks = possiblySymlinks; + } + else if (testMetaData = optionRegex.exec(line)) { + // Comment line, check for global/file @options and record them + optionRegex.lastIndex = 0; + const metaDataName = testMetaData[1].toLowerCase(); + currentFileOptions[testMetaData[1]] = testMetaData[2].trim(); + if (metaDataName !== "filename") { + continue; + } + + // New metadata statement after having collected some code to go with the previous metadata + if (currentFileName) { + // Store result file + const newTestFile = { + content: currentFileContent!, // TODO: GH#18217 + name: currentFileName, + fileOptions: currentFileOptions, + originalFilePath: fileName, + references: refs, + startLine: currentFileStartLine, + endLine: currentFileEndLine, + }; + testUnitData.push(newTestFile); + + // Reset local data + currentFileContent = undefined; + currentFileOptions = {}; + currentFileName = testMetaData[2].trim(); + currentFileStartLine = lineIndex + 1; + refs = []; + } + else { + // First metadata marker in the file + currentFileName = testMetaData[2].trim(); + currentFileStartLine = lineIndex + 1; + currentFileContent = undefined; + } + } + else { + currentFileEndLine = lineIndex; + // Subfile content line + // Append to the current subfile content, inserting a newline needed + if (currentFileContent === undefined) { + currentFileContent = ""; + currentFileStartLine = lineIndex; + } + else { + // End-of-line + currentFileContent = currentFileContent + "\n"; + } + currentFileContent = currentFileContent + line; + } + } + + // normalize the fileName for the single file case + currentFileName = testUnitData.length > 0 || currentFileName ? currentFileName : getBaseFileName(fileName); + + // EOF, push whatever remains + const newTestFile2 = { + content: currentFileContent || "", + name: currentFileName, + fileOptions: currentFileOptions, + originalFilePath: fileName, + references: refs, + startLine: currentFileStartLine, + endLine: currentFileEndLine, + }; + testUnitData.push(newTestFile2); + + // unit tests always list files explicitly + const parseConfigHost: ts.ParseConfigHost = { + useCaseSensitiveFileNames: false, + readDirectory: () => [], + fileExists: () => true, + readFile: (name) => forEach(testUnitData, data => data.name.toLowerCase() === name.toLowerCase() ? data.content : undefined) + }; + + // check if project has tsconfig.json in the list of files + let tsConfig: ts.ParsedCommandLine | undefined; + let tsConfigFileUnitData: TestUnitData | undefined; + for (let i = 0; i < testUnitData.length; i++) { + const data = testUnitData[i]; + if (getConfigNameFromFileName(data.name)) { + const configJson = ts.parseJsonText(data.name, data.content); + let baseDir = normalizePath(getDirectoryPath(data.name)); + if (rootDir) { + baseDir = getNormalizedAbsolutePath(baseDir, rootDir); + } + tsConfig = ts.parseJsonSourceFileConfigFileContent(configJson, parseConfigHost, baseDir); + tsConfig.options.configFilePath = data.name as _Path; + tsConfigFileUnitData = data; + + // delete entry from the list + orderedRemoveItemAt(testUnitData, i); + + break; + } + } + return { settings, testUnitData, tsConfig, tsConfigFileUnitData, symlinks, code }; +} \ No newline at end of file diff --git a/external-declarations/src/test-runner/tsc-infrastructure/vary-by.ts b/external-declarations/src/test-runner/tsc-infrastructure/vary-by.ts new file mode 100644 index 0000000000000..4db6d1dec2f85 --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/vary-by.ts @@ -0,0 +1,174 @@ +import { hasProperty } from "../../compiler/debug"; +import { equateStringsCaseInsensitive, map, forEach, startsWith, findIndex, arrayFrom, orderedRemoveItemAt, getEntries } from "../../compiler/lang-utils"; +import { optionDeclarations } from "./options"; +import { CompilerSettings } from "./test-file-parser"; + +export interface FileBasedTestConfiguration { + [key: string]: string; +} + +const varyBy: readonly string[] = [ + "module", + "moduleResolution", + "moduleDetection", + "target", + "jsx", + "removeComments", + "importHelpers", + "importHelpers", + "downlevelIteration", + "isolatedModules", + "strict", + "noImplicitAny", + "strictNullChecks", + "strictFunctionTypes", + "strictBindCallApply", + "strictPropertyInitialization", + "noImplicitThis", + "alwaysStrict", + "allowSyntheticDefaultImports", + "esModuleInterop", + "emitDecoratorMetadata", + "skipDefaultLibCheck", + "preserveConstEnums", + "skipLibCheck", + "exactOptionalPropertyTypes", + "useDefineForClassFields", + "useUnknownInCatchVariables", + "noUncheckedIndexedAccess", + "noPropertyAccessFromIndexSignature", +]; + +/** + * Compute FileBasedTestConfiguration variations based on a supplied list of variable settings. + */ +export function getFileBasedTestConfigurations(settings: CompilerSettings): FileBasedTestConfiguration[] | undefined { + let varyByEntries: [string, string[]][] | undefined; + let variationCount = 1; + for (const varyByKey of varyBy) { + if (hasProperty(settings, varyByKey)) { + // we only consider variations when there are 2 or more variable entries. + const entries = splitVaryBySettingValue(settings[varyByKey], varyByKey); + if (entries) { + if (!varyByEntries) varyByEntries = []; + variationCount *= entries.length; + if (variationCount > 25) throw new Error(`Provided test options exceeded the maximum number of variations: ${varyBy.map(v => `'@${v}'`).join(", ")}`); + varyByEntries.push([varyByKey, entries]); + } + } + } + + if (!varyByEntries) return undefined; + + const configurations: FileBasedTestConfiguration[] = []; + computeFileBasedTestConfigurationVariations(configurations, /*variationState*/ {}, varyByEntries, /*offset*/ 0); + return configurations; +} + +function computeFileBasedTestConfigurationVariations(configurations: FileBasedTestConfiguration[], variationState: FileBasedTestConfiguration, varyByEntries: [string, string[]][], offset: number) { + if (offset >= varyByEntries.length) { + // make a copy of the current variation state + configurations.push({ ...variationState }); + return; + } + + const [varyBy, entries] = varyByEntries[offset]; + for (const entry of entries) { + // set or overwrite the variation, then compute the next variation + variationState[varyBy] = entry; + computeFileBasedTestConfigurationVariations(configurations, variationState, varyByEntries, offset + 1); + } +} + +function splitVaryBySettingValue(text: string, varyBy: string): string[] | undefined { + if (!text) return undefined; + + let star = false; + const includes: string[] = []; + const excludes: string[] = []; + for (let s of text.split(/,/g)) { + s = s.trim().toLowerCase(); + if (s.length === 0) continue; + if (s === "*") { + star = true; + } + else if (startsWith(s, "-") || startsWith(s, "!")) { + excludes.push(s.slice(1)); + } + else { + includes.push(s); + } + } + + // do nothing if the setting has no variations + if (includes.length <= 1 && !star && excludes.length === 0) { + return undefined; + } + + const variations: { key: string, value?: string | number }[] = []; + const values = getVaryByStarSettingValues(varyBy); + + // add (and deduplicate) all included entries + for (const include of includes) { + const value = values?.get(include); + if (findIndex(variations, v => v.key === include || value !== undefined && v.value === value) === -1) { + variations.push({ key: include, value }); + } + } + + if (star && values) { + // add all entries + for (const [key, value] of arrayFrom(values.entries())) { + if (findIndex(variations, v => v.key === key || v.value === value) === -1) { + variations.push({ key, value }); + } + } + } + + // remove all excluded entries + for (const exclude of excludes) { + const value = values?.get(exclude); + let index: number; + while ((index = findIndex(variations, v => v.key === exclude || value !== undefined && v.value === value)) >= 0) { + orderedRemoveItemAt(variations, index); + } + } + + if (variations.length === 0) { + throw new Error(`Variations in test option '@${varyBy}' resulted in an empty set.`); + } + + return map(variations, v => v.key); +} + +let booleanVaryByStarSettingValues: Map | undefined; + +function getVaryByStarSettingValues(varyBy: string): ReadonlyMap | undefined { + const option = forEach(optionDeclarations, decl => equateStringsCaseInsensitive(decl.name, varyBy) ? decl : undefined); + if (option) { + if (typeof option.type === "object") { + return option.type; + } + if (option.type === "boolean") { + return booleanVaryByStarSettingValues || (booleanVaryByStarSettingValues = new Map(getEntries({ + true: 1, + false: 0 + }))); + } + } +} + +/** + * Compute a description for this configuration based on its entries + */ +export function getFileBasedTestConfigurationDescription(configuration: FileBasedTestConfiguration) { + let name = ""; + if (configuration) { + const keys = Object.keys(configuration).sort(); + for (const key of keys) { + if (name) name += ","; + name += `${key}=${configuration[key]}`; + } + } + return name; +} diff --git a/external-declarations/src/test-runner/tsc-infrastructure/vfs.ts b/external-declarations/src/test-runner/tsc-infrastructure/vfs.ts new file mode 100644 index 0000000000000..ea685e2490d7a --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/vfs.ts @@ -0,0 +1,1654 @@ +import * as collections from "./collections"; +import * as vpath from "./vpath"; +import * as documents from "./test-document"; +import * as Harness from "./compiler-run"; +import { arrayFrom } from "../../compiler/lang-utils"; + +/** + * Posix-style path to the TypeScript compiler build outputs (including tsc.js, lib.d.ts, etc.) + */ +export const builtFolder = "/.ts"; + +/** + * Posix-style path to additional mountable folders (./tests/projects in this repo) + */ +export const projectsFolder = "/.projects"; + +/** + * Posix-style path to additional test libraries + */ +export const testLibFolder = "/.lib"; + +/** + * Posix-style path to sources under test + */ +export const srcFolder = "/.src"; + +// file type +const S_IFMT = 0o170000; // file type +const S_IFSOCK = 0o140000; // socket +const S_IFLNK = 0o120000; // symbolic link +const S_IFREG = 0o100000; // regular file +const S_IFBLK = 0o060000; // block device +const S_IFDIR = 0o040000; // directory +const S_IFCHR = 0o020000; // character device +const S_IFIFO = 0o010000; // FIFO + +let devCount = 0; // A monotonically increasing count of device ids +let inoCount = 0; // A monotonically increasing count of inodes + +export interface DiffOptions { + includeChangedFileWithSameContent?: boolean; + baseIsNotShadowRoot?: boolean; +} + +export const timeIncrements = 1000; + +/** + * Represents a virtual POSIX-like file system. + */ +export class FileSystem { + /** Indicates whether the file system is case-sensitive (`false`) or case-insensitive (`true`). */ + public readonly ignoreCase: boolean; + + /** Gets the comparison function used to compare two paths. */ + public readonly stringComparer: (a: string, b: string) => number; + + // lazy-initialized state that should be mutable even if the FileSystem is frozen. + private _lazy: { + links?: collections.SortedMap; + shadows?: Map; + meta?: collections.Metadata; + } = {}; + + private _cwd: string; // current working directory + private _time: number; + private _shadowRoot: FileSystem | undefined; + private _dirStack: string[] | undefined; + + constructor(ignoreCase: boolean, options: FileSystemOptions = {}) { + const { time = timeIncrements, files, meta } = options; + this.ignoreCase = ignoreCase; + this.stringComparer = this.ignoreCase ? vpath.compareCaseInsensitive : vpath.compareCaseSensitive; + this._time = time; + + if (meta) { + for (const key of Object.keys(meta)) { + this.meta.set(key, meta[key]); + } + } + + if (files) { + this._applyFiles(files, /*dirname*/ ""); + } + + let cwd = options.cwd; + if ((!cwd || !vpath.isRoot(cwd)) && this._lazy.links) { + const iterator = collections.getIterator(this._lazy.links.keys()); + try { + for (let i = collections.nextResult(iterator); i; i = collections.nextResult(iterator)) { + const name = i.value; + cwd = cwd ? vpath.resolve(name, cwd) : name; + break; + } + } + finally { + collections.closeIterator(iterator); + } + } + + if (cwd) { + vpath.validate(cwd, vpath.ValidationFlags.Absolute); + this.mkdirpSync(cwd); + } + + this._cwd = cwd || ""; + } + + /** + * Gets metadata for this `FileSystem`. + */ + public get meta(): collections.Metadata { + if (!this._lazy.meta) { + this._lazy.meta = new collections.Metadata(this._shadowRoot ? this._shadowRoot.meta : undefined); + } + return this._lazy.meta; + } + + /** + * Gets a value indicating whether the file system is read-only. + */ + public get isReadonly() { + return Object.isFrozen(this); + } + + /** + * Makes the file system read-only. + */ + public makeReadonly() { + Object.freeze(this); + return this; + } + + /** + * Gets the file system shadowed by this file system. + */ + public get shadowRoot() { + return this._shadowRoot; + } + + /** + * Snapshots the current file system, effectively shadowing itself. This is useful for + * generating file system patches using `.diff()` from one snapshot to the next. Performs + * no action if this file system is read-only. + */ + public snapshot() { + if (this.isReadonly) return; + const fs = new FileSystem(this.ignoreCase, { time: this._time }); + fs._lazy = this._lazy; + fs._cwd = this._cwd; + fs._time = this._time; + fs._shadowRoot = this._shadowRoot; + fs._dirStack = this._dirStack; + fs.makeReadonly(); + this._lazy = {}; + this._shadowRoot = fs; + } + + /** + * Gets a shadow copy of this file system. Changes to the shadow copy do not affect the + * original, allowing multiple copies of the same core file system without multiple copies + * of the same data. + */ + public shadow(ignoreCase = this.ignoreCase) { + if (!this.isReadonly) throw new Error("Cannot shadow a mutable file system."); + if (ignoreCase && !this.ignoreCase) throw new Error("Cannot create a case-insensitive file system from a case-sensitive one."); + const fs = new FileSystem(ignoreCase, { time: this._time }); + fs._shadowRoot = this; + fs._cwd = this._cwd; + return fs; + } + + /** + * Gets or sets the timestamp (in milliseconds) used for file status, returning the previous timestamp. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/time.html + */ + public time(value?: number): number { + if (value !== undefined) { + if (this.isReadonly) throw createIOError("EPERM"); + this._time = value; + } + else if (!this.isReadonly) { + this._time += timeIncrements; + } + return this._time; + } + + /** + * Gets the metadata object for a path. + * @param path + */ + public filemeta(path: string): collections.Metadata { + const { node } = this._walk(this._resolve(path)); + if (!node) throw createIOError("ENOENT"); + return this._filemeta(node); + } + + private _filemeta(node: Inode): collections.Metadata { + if (!node.meta) { + const parentMeta = node.shadowRoot && this._shadowRoot && this._shadowRoot._filemeta(node.shadowRoot); + node.meta = new collections.Metadata(parentMeta); + } + return node.meta; + } + + /** + * Get the pathname of the current working directory. + * + * @link - http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html + */ + public cwd() { + if (!this._cwd) throw new Error("The current working directory has not been set."); + const { node } = this._walk(this._cwd); + if (!node) throw createIOError("ENOENT"); + if (!isDirectory(node)) throw createIOError("ENOTDIR"); + return this._cwd; + } + + /** + * Changes the current working directory. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/chdir.html + */ + public chdir(path: string) { + if (this.isReadonly) throw createIOError("EPERM"); + path = this._resolve(path); + const { node } = this._walk(path); + if (!node) throw createIOError("ENOENT"); + if (!isDirectory(node)) throw createIOError("ENOTDIR"); + this._cwd = path; + } + + /** + * Pushes the current directory onto the directory stack and changes the current working directory to the supplied path. + */ + public pushd(path?: string) { + if (this.isReadonly) throw createIOError("EPERM"); + if (path) path = this._resolve(path); + if (this._cwd) { + if (!this._dirStack) this._dirStack = []; + this._dirStack.push(this._cwd); + } + if (path && path !== this._cwd) { + this.chdir(path); + } + } + + /** + * Pops the previous directory from the location stack and changes the current directory to that directory. + */ + public popd() { + if (this.isReadonly) throw createIOError("EPERM"); + const path = this._dirStack && this._dirStack.pop(); + if (path) { + this.chdir(path); + } + } + + /** + * Update the file system with a set of files. + */ + public apply(files: FileSet) { + this._applyFiles(files, this._cwd); + } + + /** + * Scan file system entries along a path. If `path` is a symbolic link, it is dereferenced. + * @param path The path at which to start the scan. + * @param axis The axis along which to traverse. + * @param traversal The traversal scheme to use. + */ + public scanSync(path: string, axis: Axis, traversal: Traversal) { + path = this._resolve(path); + const results: string[] = []; + this._scan(path, this._stat(this._walk(path)), axis, traversal, /*noFollow*/ false, results); + return results; + } + + /** + * Scan file system entries along a path. + * @param path The path at which to start the scan. + * @param axis The axis along which to traverse. + * @param traversal The traversal scheme to use. + */ + public lscanSync(path: string, axis: Axis, traversal: Traversal) { + path = this._resolve(path); + const results: string[] = []; + this._scan(path, this._stat(this._walk(path, /*noFollow*/ true)), axis, traversal, /*noFollow*/ true, results); + return results; + } + + private _scan(path: string, stats: Stats, axis: Axis, traversal: Traversal, noFollow: boolean, results: string[]) { + if (axis === "ancestors-or-self" || axis === "self" || axis === "descendants-or-self") { + if (!traversal.accept || traversal.accept(path, stats)) { + results.push(path); + } + } + if (axis === "ancestors-or-self" || axis === "ancestors") { + const dirname = vpath.dirname(path); + if (dirname !== path) { + try { + const stats = this._stat(this._walk(dirname, noFollow)); + if (!traversal.traverse || traversal.traverse(dirname, stats)) { + this._scan(dirname, stats, "ancestors-or-self", traversal, noFollow, results); + } + } + catch { /*ignored*/ } + } + } + if (axis === "descendants-or-self" || axis === "descendants") { + if (stats.isDirectory() && (!traversal.traverse || traversal.traverse(path, stats))) { + for (const file of this.readdirSync(path)) { + try { + const childpath = vpath.combine(path, file); + const stats = this._stat(this._walk(childpath, noFollow)); + this._scan(childpath, stats, "descendants-or-self", traversal, noFollow, results); + } + catch { /*ignored*/ } + } + } + } + } + + /** + * Mounts a physical or virtual file system at a location in this virtual file system. + * + * @param source The path in the physical (or other virtual) file system. + * @param target The path in this virtual file system. + * @param resolver An object used to resolve files in `source`. + */ + public mountSync(source: string, target: string, resolver: FileSystemResolver) { + if (this.isReadonly) throw createIOError("EROFS"); + + source = vpath.validate(source, vpath.ValidationFlags.Absolute); + + const { parent, links, node: existingNode, basename } = this._walk(this._resolve(target), /*noFollow*/ true); + if (existingNode) throw createIOError("EEXIST"); + + const time = this.time(); + const node = this._mknod(parent ? parent.dev : ++devCount, S_IFDIR, /*mode*/ 0o777, time); + node.source = source; + node.resolver = resolver; + this._addLink(parent, links, basename, node, time); + } + + /** + * Recursively remove all files and directories underneath the provided path. + */ + public rimrafSync(path: string) { + try { + const stats = this.lstatSync(path); + if (stats.isFile() || stats.isSymbolicLink()) { + this.unlinkSync(path); + } + else if (stats.isDirectory()) { + for (const file of this.readdirSync(path)) { + this.rimrafSync(vpath.combine(path, file)); + } + this.rmdirSync(path); + } + } + catch (e) { + if (e.code === "ENOENT") return; + throw e; + } + } + + /** + * Make a directory and all of its parent paths (if they don't exist). + */ + public mkdirpSync(path: string) { + path = this._resolve(path); + const result = this._walk(path, /*noFollow*/ true, (error, result) => { + if (error.code === "ENOENT") { + this._mkdir(result); + return "retry"; + } + return "throw"; + }); + + if (!result.node) this._mkdir(result); + } + + public getFileListing(): string { + let result = ""; + const printLinks = (dirname: string | undefined, links: collections.SortedMap) => { + const iterator = collections.getIterator(links); + try { + for (let i = collections.nextResult(iterator); i; i = collections.nextResult(iterator)) { + const [name, node] = i.value; + const path = dirname ? vpath.combine(dirname, name) : name; + const marker = vpath.compare(this._cwd, path, this.ignoreCase) === 0 ? "*" : " "; + if (result) result += "\n"; + result += marker; + if (isDirectory(node)) { + result += vpath.addTrailingSeparator(path); + printLinks(path, this._getLinks(node)); + } + else if (isFile(node)) { + result += path; + } + else if (isSymlink(node)) { + result += path + " -> " + node.symlink; + } + } + } + finally { + collections.closeIterator(iterator); + } + }; + printLinks(/*dirname*/ undefined, this._getRootLinks()); + return result; + } + + /** + * Print diagnostic information about the structure of the file system to the console. + */ + public debugPrint(): void { + console.log(this.getFileListing()); + } + + // POSIX API (aligns with NodeJS "fs" module API) + + /** + * Determines whether a path exists. + */ + public existsSync(path: string) { + const result = this._walk(this._resolve(path), /*noFollow*/ true, () => "stop"); + return result !== undefined && result.node !== undefined; + } + + /** + * Get file status. If `path` is a symbolic link, it is dereferenced. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/stat.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public statSync(path: string) { + return this._stat(this._walk(this._resolve(path))); + } + + /** + * Change file access times + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public utimesSync(path: string, atime: Date, mtime: Date) { + if (this.isReadonly) throw createIOError("EROFS"); + if (!isFinite(+atime) || !isFinite(+mtime)) throw createIOError("EINVAL"); + + const entry = this._walk(this._resolve(path)); + if (!entry || !entry.node) { + throw createIOError("ENOENT"); + } + entry.node.atimeMs = +atime; + entry.node.mtimeMs = +mtime; + entry.node.ctimeMs = this.time(); + } + + /** + * Get file status. If `path` is a symbolic link, it is dereferenced. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/lstat.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public lstatSync(path: string) { + return this._stat(this._walk(this._resolve(path), /*noFollow*/ true)); + } + + + private _stat(entry: WalkResult) { + const node = entry.node; + if (!node) throw createIOError(`ENOENT`, entry.realpath); + return new Stats( + node.dev, + node.ino, + node.mode, + node.nlink, + /*rdev*/ 0, + /*size*/ isFile(node) ? this._getSize(node) : isSymlink(node) ? node.symlink.length : 0, + /*blksize*/ 4096, + /*blocks*/ 0, + node.atimeMs, + node.mtimeMs, + node.ctimeMs, + node.birthtimeMs, + ); + } + + /** + * Read a directory. If `path` is a symbolic link, it is dereferenced. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public readdirSync(path: string) { + const { node } = this._walk(this._resolve(path)); + if (!node) throw createIOError("ENOENT"); + if (!isDirectory(node)) throw createIOError("ENOTDIR"); + return Array.from(this._getLinks(node).keys()); + } + + /** + * Make a directory. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public mkdirSync(path: string) { + if (this.isReadonly) throw createIOError("EROFS"); + + this._mkdir(this._walk(this._resolve(path), /*noFollow*/ true)); + } + + private _mkdir({ parent, links, node: existingNode, basename }: WalkResult) { + if (existingNode) throw createIOError("EEXIST"); + const time = this.time(); + const node = this._mknod(parent ? parent.dev : ++devCount, S_IFDIR, /*mode*/ 0o777, time); + this._addLink(parent, links, basename, node, time); + } + + /** + * Remove a directory. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/rmdir.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public rmdirSync(path: string) { + if (this.isReadonly) throw createIOError("EROFS"); + path = this._resolve(path); + + const { parent, links, node, basename } = this._walk(path, /*noFollow*/ true); + if (!parent) throw createIOError("EPERM"); + if (!isDirectory(node)) throw createIOError("ENOTDIR"); + if (this._getLinks(node).size !== 0) throw createIOError("ENOTEMPTY"); + + this._removeLink(parent, links, basename, node); + } + + /** + * Link one file to another file (also known as a "hard link"). + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public linkSync(oldpath: string, newpath: string) { + if (this.isReadonly) throw createIOError("EROFS"); + + const { node } = this._walk(this._resolve(oldpath)); + if (!node) throw createIOError("ENOENT"); + if (isDirectory(node)) throw createIOError("EPERM"); + + const { parent, links, basename, node: existingNode } = this._walk(this._resolve(newpath), /*noFollow*/ true); + if (!parent) throw createIOError("EPERM"); + if (existingNode) throw createIOError("EEXIST"); + + this._addLink(parent, links, basename, node); + } + + /** + * Remove a directory entry. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public unlinkSync(path: string) { + if (this.isReadonly) throw createIOError("EROFS"); + + const { parent, links, node, basename } = this._walk(this._resolve(path), /*noFollow*/ true); + if (!parent) throw createIOError("EPERM"); + if (!node) throw createIOError("ENOENT"); + if (isDirectory(node)) throw createIOError("EISDIR"); + + this._removeLink(parent, links, basename, node); + } + + /** + * Rename a file. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public renameSync(oldpath: string, newpath: string) { + if (this.isReadonly) throw createIOError("EROFS"); + + const { parent: oldParent, links: oldParentLinks, node, basename: oldBasename } = this._walk(this._resolve(oldpath), /*noFollow*/ true); + if (!oldParent) throw createIOError("EPERM"); + if (!node) throw createIOError("ENOENT"); + + const { parent: newParent, links: newParentLinks, node: existingNode, basename: newBasename } = this._walk(this._resolve(newpath), /*noFollow*/ true); + if (!newParent) throw createIOError("EPERM"); + + const time = this.time(); + if (existingNode) { + if (isDirectory(node)) { + if (!isDirectory(existingNode)) throw createIOError("ENOTDIR"); + // if both old and new arguments point to the same directory, just pass. So we could rename /src/a/1 to /src/A/1 in Win. + // if not and the directory pointed by the new path is not empty, throw an error. + if (this.stringComparer(oldpath, newpath) !== 0 && this._getLinks(existingNode).size > 0) throw createIOError("ENOTEMPTY"); + } + else { + if (isDirectory(existingNode)) throw createIOError("EISDIR"); + } + this._removeLink(newParent, newParentLinks, newBasename, existingNode, time); + } + + this._replaceLink(oldParent, oldParentLinks, oldBasename, newParent, newParentLinks, newBasename, node, time); + } + + /** + * Make a symbolic link. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public symlinkSync(target: string, linkpath: string) { + if (this.isReadonly) throw createIOError("EROFS"); + + const { parent, links, node: existingNode, basename } = this._walk(this._resolve(linkpath), /*noFollow*/ true); + if (!parent) throw createIOError("EPERM"); + if (existingNode) throw createIOError("EEXIST"); + + const time = this.time(); + const node = this._mknod(parent.dev, S_IFLNK, /*mode*/ 0o666, time); + node.symlink = vpath.validate(target, vpath.ValidationFlags.RelativeOrAbsolute); + this._addLink(parent, links, basename, node, time); + } + + /** + * Resolve a pathname. + * + * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public realpathSync(path: string) { + const { realpath } = this._walk(this._resolve(path)); + return realpath; + } + + /** + * Read from a file. + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public readFileSync(path: string, encoding?: null): Buffer; + /** + * Read from a file. + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public readFileSync(path: string, encoding: BufferEncoding): string; + /** + * Read from a file. + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + public readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer; + public readFileSync(path: string, encoding: BufferEncoding | null = null) { // eslint-disable-line no-null/no-null + const { node } = this._walk(this._resolve(path)); + if (!node) throw createIOError("ENOENT"); + if (isDirectory(node)) throw createIOError("EISDIR"); + if (!isFile(node)) throw createIOError("EBADF"); + + const buffer = this._getBuffer(node).slice(); + return encoding ? buffer.toString(encoding) : buffer; + } + + /** + * Write to a file. + * + * NOTE: do not rename this method as it is intended to align with the same named export of the "fs" module. + */ + // eslint-disable-next-line no-null/no-null + public writeFileSync(path: string, data: string | Buffer, encoding: string | null = null) { + if (this.isReadonly) throw createIOError("EROFS"); + + const { parent, links, node: existingNode, basename } = this._walk(this._resolve(path), /*noFollow*/ false); + if (!parent) throw createIOError("EPERM"); + + const time = this.time(); + let node = existingNode; + if (!node) { + node = this._mknod(parent.dev, S_IFREG, 0o666, time); + this._addLink(parent, links, basename, node, time); + } + + if (isDirectory(node)) throw createIOError("EISDIR"); + if (!isFile(node)) throw createIOError("EBADF"); + node.buffer = Buffer.isBuffer(data) ? data.slice() : sys.bufferFrom!("" + data, encoding || "utf8") as Buffer; + node.size = node.buffer.byteLength; + node.mtimeMs = time; + node.ctimeMs = time; + } + + /** + * Generates a `FileSet` patch containing all the entries in this `FileSystem` that are not in `base`. + * @param base The base file system. If not provided, this file system's `shadowRoot` is used (if present). + */ + public diff(base?: FileSystem | undefined, options: DiffOptions = {}) { + if (!base && !options.baseIsNotShadowRoot) base = this.shadowRoot; + const differences: FileSet = {}; + const hasDifferences = base ? + FileSystem.rootDiff(differences, this, base, options) : + FileSystem.trackCreatedInodes(differences, this, this._getRootLinks()); + return hasDifferences ? differences : undefined; + } + + /** + * Generates a `FileSet` patch containing all the entries in `changed` that are not in `base`. + */ + public static diff(changed: FileSystem, base: FileSystem, options: DiffOptions = {}) { + const differences: FileSet = {}; + return FileSystem.rootDiff(differences, changed, base, options) ? + differences : + undefined; + } + + private static diffWorker(container: FileSet, changed: FileSystem, changedLinks: ReadonlyMap | undefined, base: FileSystem, baseLinks: ReadonlyMap | undefined, options: DiffOptions) { + if (changedLinks && !baseLinks) return FileSystem.trackCreatedInodes(container, changed, changedLinks); + if (baseLinks && !changedLinks) return FileSystem.trackDeletedInodes(container, baseLinks); + if (changedLinks && baseLinks) { + let hasChanges = false; + // track base items missing in changed + baseLinks.forEach((node, basename) => { + if (!changedLinks.has(basename)) { + container[basename] = isDirectory(node) ? new Rmdir() : new Unlink(); + hasChanges = true; + } + }); + // track changed items missing or differing in base + changedLinks.forEach((changedNode, basename) => { + const baseNode = baseLinks.get(basename); + if (baseNode) { + if (isDirectory(changedNode) && isDirectory(baseNode)) { + return hasChanges = FileSystem.directoryDiff(container, basename, changed, changedNode, base, baseNode, options) || hasChanges; + } + if (isFile(changedNode) && isFile(baseNode)) { + return hasChanges = FileSystem.fileDiff(container, basename, changed, changedNode, base, baseNode, options) || hasChanges; + } + if (isSymlink(changedNode) && isSymlink(baseNode)) { + return hasChanges = FileSystem.symlinkDiff(container, basename, changedNode, baseNode) || hasChanges; + } + } + return hasChanges = FileSystem.trackCreatedInode(container, basename, changed, changedNode) || hasChanges; + }); + return hasChanges; + } + return false; + } + + private static rootDiff(container: FileSet, changed: FileSystem, base: FileSystem, options: DiffOptions) { + while (!changed._lazy.links && changed._shadowRoot) changed = changed._shadowRoot; + while (!base._lazy.links && base._shadowRoot) base = base._shadowRoot; + + // no difference if the file systems are the same reference + if (changed === base) return false; + + // no difference if the root links are empty and unshadowed + if (!changed._lazy.links && !changed._shadowRoot && !base._lazy.links && !base._shadowRoot) return false; + + return FileSystem.diffWorker(container, changed, changed._getRootLinks(), base, base._getRootLinks(), options); + } + + private static directoryDiff(container: FileSet, basename: string, changed: FileSystem, changedNode: DirectoryInode, base: FileSystem, baseNode: DirectoryInode, options: DiffOptions) { + while (!changedNode.links && changedNode.shadowRoot) changedNode = changedNode.shadowRoot; + while (!baseNode.links && baseNode.shadowRoot) baseNode = baseNode.shadowRoot; + + // no difference if the nodes are the same reference + if (changedNode === baseNode) return false; + + // no difference if both nodes are non shadowed and have no entries + if (isEmptyNonShadowedDirectory(changedNode) && isEmptyNonShadowedDirectory(baseNode)) return false; + + // no difference if both nodes are unpopulated and point to the same mounted file system + if (!changedNode.links && !baseNode.links && + changedNode.resolver && changedNode.source !== undefined && + baseNode.resolver === changedNode.resolver && baseNode.source === changedNode.source) return false; + + // no difference if both nodes have identical children + const children: FileSet = {}; + if (!FileSystem.diffWorker(children, changed, changed._getLinks(changedNode), base, base._getLinks(baseNode), options)) { + return false; + } + + container[basename] = new Directory(children); + return true; + } + + private static fileDiff(container: FileSet, basename: string, changed: FileSystem, changedNode: FileInode, base: FileSystem, baseNode: FileInode, options: DiffOptions) { + while (!changedNode.buffer && changedNode.shadowRoot) changedNode = changedNode.shadowRoot; + while (!baseNode.buffer && baseNode.shadowRoot) baseNode = baseNode.shadowRoot; + + // no difference if the nodes are the same reference + if (changedNode === baseNode) return false; + + // no difference if both nodes are non shadowed and have no entries + if (isEmptyNonShadowedFile(changedNode) && isEmptyNonShadowedFile(baseNode)) return false; + + // no difference if both nodes are unpopulated and point to the same mounted file system + if (!changedNode.buffer && !baseNode.buffer && + changedNode.resolver && changedNode.source !== undefined && + baseNode.resolver === changedNode.resolver && baseNode.source === changedNode.source) return false; + + const changedBuffer = changed._getBuffer(changedNode); + const baseBuffer = base._getBuffer(baseNode); + + // no difference if both buffers are the same reference + if (changedBuffer === baseBuffer) { + if (!options.includeChangedFileWithSameContent || changedNode.mtimeMs === baseNode.mtimeMs) return false; + container[basename] = new SameFileWithModifiedTime(changedBuffer); + return true; + } + + // no difference if both buffers are identical + if (Buffer.compare(changedBuffer, baseBuffer) === 0) { + if (!options.includeChangedFileWithSameContent) return false; + container[basename] = new SameFileContentFile(changedBuffer); + return true; + } + + container[basename] = new File(changedBuffer); + return true; + } + + private static symlinkDiff(container: FileSet, basename: string, changedNode: SymlinkInode, baseNode: SymlinkInode) { + // no difference if the nodes are the same reference + if (changedNode.symlink === baseNode.symlink) return false; + container[basename] = new Symlink(changedNode.symlink); + return true; + } + + private static trackCreatedInode(container: FileSet, basename: string, changed: FileSystem, node: Inode) { + if (isDirectory(node)) { + const children: FileSet = {}; + FileSystem.trackCreatedInodes(children, changed, changed._getLinks(node)); + container[basename] = new Directory(children); + } + else if (isSymlink(node)) { + container[basename] = new Symlink(node.symlink); + } + else { + container[basename] = new File(changed._getBuffer(node)); + } + return true; + } + + private static trackCreatedInodes(container: FileSet, changed: FileSystem, changedLinks: ReadonlyMap) { + // no difference if links are empty + if (!changedLinks.size) return false; + + changedLinks.forEach((node, basename) => { + FileSystem.trackCreatedInode(container, basename, changed, node); + }); + return true; + } + + private static trackDeletedInodes(container: FileSet, baseLinks: ReadonlyMap) { + // no difference if links are empty + if (!baseLinks.size) return false; + baseLinks.forEach((node, basename) => { + container[basename] = isDirectory(node) ? new Rmdir() : new Unlink(); + }); + return true; + } + + private _mknod(dev: number, type: typeof S_IFREG, mode: number, time?: number): FileInode; + private _mknod(dev: number, type: typeof S_IFDIR, mode: number, time?: number): DirectoryInode; + private _mknod(dev: number, type: typeof S_IFLNK, mode: number, time?: number): SymlinkInode; + private _mknod(dev: number, type: number, mode: number, time = this.time()) { + return { + dev, + ino: ++inoCount, + mode: (mode & ~S_IFMT & ~0o022 & 0o7777) | (type & S_IFMT), + atimeMs: time, + mtimeMs: time, + ctimeMs: time, + birthtimeMs: time, + nlink: 0 + } as Inode; + } + + private _addLink(parent: DirectoryInode | undefined, links: collections.SortedMap, name: string, node: Inode, time = this.time()) { + links.set(name, node); + node.nlink++; + node.ctimeMs = time; + if (parent) parent.mtimeMs = time; + if (!parent && !this._cwd) this._cwd = name; + } + + private _removeLink(parent: DirectoryInode | undefined, links: collections.SortedMap, name: string, node: Inode, time = this.time()) { + links.delete(name); + node.nlink--; + node.ctimeMs = time; + if (parent) parent.mtimeMs = time; + } + + private _replaceLink(oldParent: DirectoryInode, oldLinks: collections.SortedMap, oldName: string, newParent: DirectoryInode, newLinks: collections.SortedMap, newName: string, node: Inode, time: number) { + if (oldParent !== newParent) { + this._removeLink(oldParent, oldLinks, oldName, node, time); + this._addLink(newParent, newLinks, newName, node, time); + } + else { + oldLinks.delete(oldName); + oldLinks.set(newName, node); + oldParent.mtimeMs = time; + newParent.mtimeMs = time; + } + } + + private _getRootLinks() { + if (!this._lazy.links) { + this._lazy.links = new collections.SortedMap(this.stringComparer); + if (this._shadowRoot) { + this._copyShadowLinks(this._shadowRoot._getRootLinks(), this._lazy.links); + } + } + return this._lazy.links; + } + + private _getLinks(node: DirectoryInode) { + if (!node.links) { + const links = new collections.SortedMap(this.stringComparer); + const { source, resolver } = node; + if (source && resolver) { + node.source = undefined; + node.resolver = undefined; + for (const name of resolver.readdirSync(source)) { + const path = vpath.combine(source, name); + const stats = resolver.statSync(path); + switch (stats.mode & S_IFMT) { + case S_IFDIR: + const dir = this._mknod(node.dev, S_IFDIR, 0o777); + dir.source = vpath.combine(source, name); + dir.resolver = resolver; + this._addLink(node, links, name, dir); + break; + case S_IFREG: + const file = this._mknod(node.dev, S_IFREG, 0o666); + file.source = vpath.combine(source, name); + file.resolver = resolver; + file.size = stats.size; + this._addLink(node, links, name, file); + break; + } + } + } + else if (this._shadowRoot && node.shadowRoot) { + this._copyShadowLinks(this._shadowRoot._getLinks(node.shadowRoot), links); + } + node.links = links; + } + return node.links; + } + + private _getShadow(root: DirectoryInode): DirectoryInode; + private _getShadow(root: Inode): Inode; + private _getShadow(root: Inode) { + const shadows = this._lazy.shadows || (this._lazy.shadows = new Map()); + + let shadow = shadows.get(root.ino); + if (!shadow) { + shadow = { + dev: root.dev, + ino: root.ino, + mode: root.mode, + atimeMs: root.atimeMs, + mtimeMs: root.mtimeMs, + ctimeMs: root.ctimeMs, + birthtimeMs: root.birthtimeMs, + nlink: root.nlink, + shadowRoot: root + } as Inode; + + if (isSymlink(root)) (shadow as SymlinkInode).symlink = root.symlink; + shadows.set(shadow.ino, shadow); + } + + return shadow; + } + + private _copyShadowLinks(source: ReadonlyMap, target: collections.SortedMap) { + const iterator = collections.getIterator(source); + try { + for (let i = collections.nextResult(iterator); i; i = collections.nextResult(iterator)) { + const [name, root] = i.value; + target.set(name, this._getShadow(root)); + } + } + finally { + collections.closeIterator(iterator); + } + } + + private _getSize(node: FileInode): number { + if (node.buffer) return node.buffer.byteLength; + if (node.size !== undefined) return node.size; + if (node.source && node.resolver) return node.size = node.resolver.statSync(node.source).size; + if (this._shadowRoot && node.shadowRoot) return node.size = this._shadowRoot._getSize(node.shadowRoot); + return 0; + } + + private _getBuffer(node: FileInode): Buffer { + if (!node.buffer) { + const { source, resolver } = node; + if (source && resolver) { + node.source = undefined; + node.resolver = undefined; + node.size = undefined; + node.buffer = resolver.readFileSync(source); + } + else if (this._shadowRoot && node.shadowRoot) { + node.buffer = this._shadowRoot._getBuffer(node.shadowRoot); + } + else { + node.buffer = Buffer.allocUnsafe(0); + } + } + return node.buffer; + } + + /** + * Walk a path to its end. + * + * @param path The path to follow. + * @param noFollow A value indicating whether to *not* dereference a symbolic link at the + * end of a path. + * + * @link http://man7.org/linux/man-pages/man7/path_resolution.7.html + */ + private _walk(path: string, noFollow?: boolean, onError?: (error: NodeJS.ErrnoException, fragment: WalkResult) => "retry" | "throw"): WalkResult; + private _walk(path: string, noFollow?: boolean, onError?: (error: NodeJS.ErrnoException, fragment: WalkResult) => "stop" | "retry" | "throw"): WalkResult | undefined; + private _walk(path: string, noFollow?: boolean, onError?: (error: NodeJS.ErrnoException, fragment: WalkResult) => "stop" | "retry" | "throw"): WalkResult | undefined { + let links = this._getRootLinks(); + let parent: DirectoryInode | undefined; + let components = vpath.parse(path); + let step = 0; + let depth = 0; + let retry = false; + while (true) { + if (depth >= 40) throw createIOError("ELOOP"); + const lastStep = step === components.length - 1; + let basename = components[step]; + const linkEntry = links.getEntry(basename); + if (linkEntry) { + components[step] = basename = linkEntry[0]; + } + const node = linkEntry?.[1]; + if (lastStep && (noFollow || !isSymlink(node))) { + return { realpath: vpath.format(components), basename, parent, links, node }; + } + if (node === undefined) { + if (trapError(createIOError("ENOENT"), node)) continue; + return undefined; + } + if (isSymlink(node)) { + const dirname = vpath.format(components.slice(0, step)); + const symlink = vpath.resolve(dirname, node.symlink); + links = this._getRootLinks(); + parent = undefined; + components = vpath.parse(symlink).concat(components.slice(step + 1)); + step = 0; + depth++; + retry = false; + continue; + } + if (isDirectory(node)) { + links = this._getLinks(node); + parent = node; + step++; + retry = false; + continue; + } + if (trapError(createIOError("ENOTDIR"), node)) continue; + return undefined; + } + + function trapError(error: NodeJS.ErrnoException, node?: Inode) { + const realpath = vpath.format(components.slice(0, step + 1)); + const basename = components[step]; + const result = !retry && onError ? onError(error, { realpath, basename, parent, links, node }) : "throw"; + if (result === "stop") return false; + if (result === "retry") { + retry = true; + return true; + } + throw error; + } + } + + /** + * Resolve a path relative to the current working directory. + */ + private _resolve(path: string) { + return this._cwd + ? vpath.resolve(this._cwd, vpath.validate(path, vpath.ValidationFlags.RelativeOrAbsolute | vpath.ValidationFlags.AllowWildcard)) + : vpath.validate(path, vpath.ValidationFlags.Absolute | vpath.ValidationFlags.AllowWildcard); + } + + private _applyFiles(files: FileSet, dirname: string) { + const deferred: [Symlink | Link | Mount, string][] = []; + this._applyFilesWorker(files, dirname, deferred); + for (const [entry, path] of deferred) { + this.mkdirpSync(vpath.dirname(path)); + this.pushd(vpath.dirname(path)); + if (entry instanceof Symlink) { + if (this.stringComparer(vpath.dirname(path), path) === 0) { + throw new TypeError("Roots cannot be symbolic links."); + } + this.symlinkSync(vpath.resolve(dirname, entry.symlink), path); + this._applyFileExtendedOptions(path, entry); + } + else if (entry instanceof Link) { + if (this.stringComparer(vpath.dirname(path), path) === 0) { + throw new TypeError("Roots cannot be hard links."); + } + this.linkSync(entry.path, path); + } + else { + this.mountSync(entry.source, path, entry.resolver); + this._applyFileExtendedOptions(path, entry); + } + this.popd(); + } + } + + private _applyFileExtendedOptions(path: string, entry: Directory | File | Symlink | Mount) { + const { meta } = entry; + if (meta !== undefined) { + const filemeta = this.filemeta(path); + for (const key of Object.keys(meta)) { + filemeta.set(key, meta[key]); + } + } + } + + private _applyFilesWorker(files: FileSet, dirname: string, deferred: [Symlink | Link | Mount, string][]) { + for (const key of Object.keys(files)) { + const value = normalizeFileSetEntry(files[key]); + const path = dirname ? vpath.resolve(dirname, key) : key; + vpath.validate(path, vpath.ValidationFlags.Absolute); + + // eslint-disable-next-line no-null/no-null + if (value === null || value === undefined || value instanceof Rmdir || value instanceof Unlink) { + if (this.stringComparer(vpath.dirname(path), path) === 0) { + throw new TypeError("Roots cannot be deleted."); + } + this.rimrafSync(path); + } + else if (value instanceof File) { + if (this.stringComparer(vpath.dirname(path), path) === 0) { + throw new TypeError("Roots cannot be files."); + } + this.mkdirpSync(vpath.dirname(path)); + this.writeFileSync(path, value.data, value.encoding); + this._applyFileExtendedOptions(path, value); + } + else if (value instanceof Directory) { + this.mkdirpSync(path); + this._applyFileExtendedOptions(path, value); + this._applyFilesWorker(value.files, path, deferred); + } + else { + deferred.push([value, path]); + } + } + } +} + +export interface FileSystemOptions { + // Sets the initial timestamp for new files and directories + time?: number; + + // A set of file system entries to initially add to the file system. + files?: FileSet; + + // Sets the initial working directory for the file system. + cwd?: string; + + // Sets initial metadata attached to the file system. + meta?: Record; +} + +export interface FileSystemCreateOptions extends FileSystemOptions { + // Sets the documents to add to the file system. + documents?: readonly documents.TextDocument[]; +} + +export type Axis = "ancestors" | "ancestors-or-self" | "self" | "descendants-or-self" | "descendants"; + +export interface Traversal { + /** A function called to choose whether to continue to traverse to either ancestors or descendants. */ + traverse?(path: string, stats: Stats): boolean; + /** A function called to choose whether to accept a path as part of the result. */ + accept?(path: string, stats: Stats): boolean; +} + +export interface FileSystemResolver { + statSync(path: string): { mode: number; size: number; }; + readdirSync(path: string): string[]; + readFileSync(path: string): Buffer; +} + +/** @internal */ +export interface FileSystemEntries { + readonly files: readonly string[]; + readonly directories: readonly string[]; +} + +export interface FileSystemResolverHost { + useCaseSensitiveFileNames(): boolean; + getAccessibleFileSystemEntries(path: string): FileSystemEntries; + directoryExists(path: string): boolean; + fileExists(path: string): boolean; + getFileSize(path: string): number; + readFile(path: string): string | undefined; + getWorkspaceRoot(): string; +} + +export function createResolver(host: FileSystemResolverHost): FileSystemResolver { + return { + readdirSync(path: string): string[] { + const { files, directories } = host.getAccessibleFileSystemEntries(path); + return directories.concat(files); + }, + statSync(path: string): { mode: number; size: number; } { + if (host.directoryExists(path)) { + return { mode: S_IFDIR | 0o777, size: 0 }; + } + else if (host.fileExists(path)) { + return { mode: S_IFREG | 0o666, size: host.getFileSize(path) }; + } + else { + throw new Error("ENOENT: path does not exist"); + } + }, + readFileSync(path: string): Buffer { + return sys.bufferFrom!(host.readFile(path)!, "utf8") as Buffer; // TODO: GH#18217 + } + }; +} +namespace sys { + const Buffer: { + new (input: string, encoding?: string): any; + from?(input: string, encoding?: string): any; + } = require("buffer").Buffer; + + export function bufferFrom(input: string, encoding?: string): Buffer { + // See https://github.com/Microsoft/TypeScript/issues/25652 + return Buffer.from && (Buffer.from as Function) !== Int8Array.from + ? Buffer.from(input, encoding) + : new Buffer(input, encoding); + } +} +/** + * Create a virtual file system from a physical file system using the following path mappings: + * + * - `/.ts` is a directory mapped to `${workspaceRoot}/built/local` + * - `/.lib` is a directory mapped to `${workspaceRoot}/tests/lib` + * - `/.src` is a virtual directory to be used for tests. + * + * Unless overridden, `/.src` will be the current working directory for the virtual file system. + */ +export function createFromFileSystem(host: FileSystemResolverHost, ignoreCase: boolean, { documents, files, cwd, time, meta }: FileSystemCreateOptions = {}) { + const fs = getBuiltLocal(host, ignoreCase).shadow(); + if (meta) { + for (const key of Object.keys(meta)) { + fs.meta.set(key, meta[key]); + } + } + if (time) { + fs.time(time); + } + if (cwd) { + fs.mkdirpSync(cwd); + fs.chdir(cwd); + } + if (documents) { + for (const document of documents) { + fs.mkdirpSync(vpath.dirname(document.file)); + fs.writeFileSync(document.file, document.text, "utf8"); + fs.filemeta(document.file).set("document", document); + // Add symlinks + const symlink = document.meta.get("symlink"); + if (symlink) { + for (const link of symlink.split(",").map(link => link.trim())) { + fs.mkdirpSync(vpath.dirname(link)); + fs.symlinkSync(vpath.resolve(fs.cwd(), document.file), link); + } + } + } + } + if (files) { + fs.apply(files); + } + return fs; +} + +export class Stats { + public dev: number; + public ino: number; + public mode: number; + public nlink: number; + public uid: number; + public gid: number; + public rdev: number; + public size: number; + public blksize: number; + public blocks: number; + public atimeMs: number; + public mtimeMs: number; + public ctimeMs: number; + public birthtimeMs: number; + public atime: Date; + public mtime: Date; + public ctime: Date; + public birthtime: Date; + + constructor(); + constructor(dev: number, ino: number, mode: number, nlink: number, rdev: number, size: number, blksize: number, blocks: number, atimeMs: number, mtimeMs: number, ctimeMs: number, birthtimeMs: number); + constructor(dev = 0, ino = 0, mode = 0, nlink = 0, rdev = 0, size = 0, blksize = 0, blocks = 0, atimeMs = 0, mtimeMs = 0, ctimeMs = 0, birthtimeMs = 0) { + this.dev = dev; + this.ino = ino; + this.mode = mode; + this.nlink = nlink; + this.uid = 0; + this.gid = 0; + this.rdev = rdev; + this.size = size; + this.blksize = blksize; + this.blocks = blocks; + this.atimeMs = atimeMs; + this.mtimeMs = mtimeMs; + this.ctimeMs = ctimeMs; + this.birthtimeMs = birthtimeMs; + this.atime = new Date(this.atimeMs); + this.mtime = new Date(this.mtimeMs); + this.ctime = new Date(this.ctimeMs); + this.birthtime = new Date(this.birthtimeMs); + } + + public isFile() { return (this.mode & S_IFMT) === S_IFREG; } + public isDirectory() { return (this.mode & S_IFMT) === S_IFDIR; } + public isSymbolicLink() { return (this.mode & S_IFMT) === S_IFLNK; } + public isBlockDevice() { return (this.mode & S_IFMT) === S_IFBLK; } + public isCharacterDevice() { return (this.mode & S_IFMT) === S_IFCHR; } + public isFIFO() { return (this.mode & S_IFMT) === S_IFIFO; } + public isSocket() { return (this.mode & S_IFMT) === S_IFSOCK; } +} + +export const IOErrorMessages = Object.freeze({ + EACCES: "access denied", + EIO: "an I/O error occurred", + ENOENT: "no such file or directory", + EEXIST: "file already exists", + ELOOP: "too many symbolic links encountered", + ENOTDIR: "no such directory", + EISDIR: "path is a directory", + EBADF: "invalid file descriptor", + EINVAL: "invalid value", + ENOTEMPTY: "directory not empty", + EPERM: "operation not permitted", + EROFS: "file system is read-only" +}); + +export function createIOError(code: keyof typeof IOErrorMessages, details = "") { + const err: NodeJS.ErrnoException = new Error(`${code}: ${IOErrorMessages[code]} ${details}`); + err.code = code; + if (Error.captureStackTrace) Error.captureStackTrace(err, createIOError); + return err; +} + +/** + * A template used to populate files, directories, links, etc. in a virtual file system. + */ +export interface FileSet { + [name: string]: DirectoryLike | FileLike | Link | Symlink | Mount | Rmdir | Unlink | null | undefined; +} + +export type DirectoryLike = FileSet | Directory; +export type FileLike = File | Buffer | string; + +/** Extended options for a directory in a `FileSet` */ +export class Directory { + public readonly files: FileSet; + public readonly meta: Record | undefined; + constructor(files: FileSet, { meta }: { meta?: Record } = {}) { + this.files = files; + this.meta = meta; + } +} + +/** Extended options for a file in a `FileSet` */ +export class File { + public readonly data: Buffer | string; + public readonly encoding: string | undefined; + public readonly meta: Record | undefined; + constructor(data: Buffer | string, { meta, encoding }: { encoding?: string, meta?: Record } = {}) { + this.data = data; + this.encoding = encoding; + this.meta = meta; + } +} + +export class SameFileContentFile extends File { + constructor(data: Buffer | string, metaAndEncoding?: { encoding?: string, meta?: Record }) { + super(data, metaAndEncoding); + } +} + +export class SameFileWithModifiedTime extends File { + constructor(data: Buffer | string, metaAndEncoding?: { encoding?: string, meta?: Record }) { + super(data, metaAndEncoding); + } +} + +/** Extended options for a hard link in a `FileSet` */ +export class Link { + public readonly path: string; + constructor(path: string) { + this.path = path; + } +} + +/** Removes a directory in a `FileSet` */ +export class Rmdir { + public _rmdirBrand?: never; // brand necessary for proper type guards +} + +/** Unlinks a file in a `FileSet` */ +export class Unlink { + public _unlinkBrand?: never; // brand necessary for proper type guards +} + +/** Extended options for a symbolic link in a `FileSet` */ +export class Symlink { + public readonly symlink: string; + public readonly meta: Record | undefined; + constructor(symlink: string, { meta }: { meta?: Record } = {}) { + this.symlink = symlink; + this.meta = meta; + } +} + +/** Extended options for mounting a virtual copy of an external file system via a `FileSet` */ +export class Mount { + public readonly source: string; + public readonly resolver: FileSystemResolver; + public readonly meta: Record | undefined; + constructor(source: string, resolver: FileSystemResolver, { meta }: { meta?: Record } = {}) { + this.source = source; + this.resolver = resolver; + this.meta = meta; + } +} + +// a generic POSIX inode +type Inode = FileInode | DirectoryInode | SymlinkInode; + +interface FileInode { + dev: number; // device id + ino: number; // inode id + mode: number; // file mode + atimeMs: number; // access time + mtimeMs: number; // modified time + ctimeMs: number; // status change time + birthtimeMs: number; // creation time + nlink: number; // number of hard links + size?: number; + buffer?: Buffer; + source?: string; + resolver?: FileSystemResolver; + shadowRoot?: FileInode; + meta?: collections.Metadata; +} + +interface DirectoryInode { + dev: number; // device id + ino: number; // inode id + mode: number; // file mode + atimeMs: number; // access time + mtimeMs: number; // modified time + ctimeMs: number; // status change time + birthtimeMs: number; // creation time + nlink: number; // number of hard links + links?: collections.SortedMap; + source?: string; + resolver?: FileSystemResolver; + shadowRoot?: DirectoryInode; + meta?: collections.Metadata; +} + +interface SymlinkInode { + dev: number; // device id + ino: number; // inode id + mode: number; // file mode + atimeMs: number; // access time + mtimeMs: number; // modified time + ctimeMs: number; // status change time + birthtimeMs: number; // creation time + nlink: number; // number of hard links + symlink: string; + shadowRoot?: SymlinkInode; + meta?: collections.Metadata; +} + +function isEmptyNonShadowedDirectory(node: DirectoryInode) { + return !node.links && !node.shadowRoot && !node.resolver && !node.source; +} + +function isEmptyNonShadowedFile(node: FileInode) { + return !node.buffer && !node.shadowRoot && !node.resolver && !node.source; +} + +function isFile(node: Inode | undefined): node is FileInode { + return node !== undefined && (node.mode & S_IFMT) === S_IFREG; +} + +function isDirectory(node: Inode | undefined): node is DirectoryInode { + return node !== undefined && (node.mode & S_IFMT) === S_IFDIR; +} + +function isSymlink(node: Inode | undefined): node is SymlinkInode { + return node !== undefined && (node.mode & S_IFMT) === S_IFLNK; +} + +interface WalkResult { + realpath: string; + basename: string; + parent: DirectoryInode | undefined; + links: collections.SortedMap; + node: Inode | undefined; +} + +let builtLocalHost: FileSystemResolverHost | undefined; +let builtLocalCI: FileSystem | undefined; +let builtLocalCS: FileSystem | undefined; + +function getBuiltLocal(host: FileSystemResolverHost, ignoreCase: boolean): FileSystem { + if (builtLocalHost !== host) { + builtLocalCI = undefined; + builtLocalCS = undefined; + builtLocalHost = host; + } + if (!builtLocalCI) { + const resolver = createResolver(host); + builtLocalCI = new FileSystem(/*ignoreCase*/ true, { + files: { + [builtFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "built/local"), resolver), + [testLibFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "tests/lib"), resolver), + [projectsFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "tests/projects"), resolver), + [srcFolder]: {} + }, + cwd: srcFolder, + meta: { defaultLibLocation: builtFolder } + }); + builtLocalCI.makeReadonly(); + } + if (ignoreCase) return builtLocalCI; + if (!builtLocalCS) { + builtLocalCS = builtLocalCI.shadow(/*ignoreCase*/ false); + builtLocalCS.makeReadonly(); + } + return builtLocalCS; +} + +/* eslint-disable no-null/no-null */ +function normalizeFileSetEntry(value: FileSet[string]) { + if (value === undefined || + value === null || + value instanceof Directory || + value instanceof File || + value instanceof Link || + value instanceof Symlink || + value instanceof Mount || + value instanceof Rmdir || + value instanceof Unlink) { + return value; + } + return typeof value === "string" || Buffer.isBuffer(value) ? new File(value) : new Directory(value); +} + +export function formatPatch(patch: FileSet): string; +export function formatPatch(patch: FileSet | undefined): string | null; +export function formatPatch(patch: FileSet | undefined) { + return patch ? formatPatchWorker("", patch) : null; +} +/* eslint-enable no-null/no-null */ + +function formatPatchWorker(dirname: string, container: FileSet): string { + let text = ""; + for (const name of Object.keys(container)) { + const entry = normalizeFileSetEntry(container[name]); + const file = dirname ? vpath.combine(dirname, name) : name; + // eslint-disable-next-line no-null/no-null + if (entry === null || entry === undefined || entry instanceof Unlink) { + text += `//// [${file}] unlink\r\n`; + } + else if (entry instanceof Rmdir) { + text += `//// [${vpath.addTrailingSeparator(file)}] rmdir\r\n`; + } + else if (entry instanceof Directory) { + text += formatPatchWorker(file, entry.files); + } + else if (entry instanceof SameFileWithModifiedTime) { + text += `//// [${file}] file changed its modified time\r\n`; + } + else if (entry instanceof SameFileContentFile) { + text += `//// [${file}] file written with same contents\r\n`; + } + else if (entry instanceof File) { + const content = typeof entry.data === "string" ? entry.data : entry.data.toString("utf8"); + text += `//// [${file}]\r\n${content}\r\n\r\n`; + } + else if (entry instanceof Link) { + text += `//// [${file}] link(${entry.path})\r\n`; + } + else if (entry instanceof Symlink) { + text += `//// [${file}] symlink(${entry.symlink})\r\n`; + } + else if (entry instanceof Mount) { + text += `//// [${file}] mount(${entry.source})\r\n`; + } + } + return text; +} + +export function iteratePatch(patch: FileSet | undefined): IterableIterator<[string, string]> | null { + // eslint-disable-next-line no-null/no-null + return patch ? Harness.iterateOutputs(iteratePatchWorker("", patch)) : null; +} + +function* iteratePatchWorker(dirname: string, container: FileSet): IterableIterator { + for (const name of Object.keys(container)) { + const entry = normalizeFileSetEntry(container[name]); + const file = dirname ? vpath.combine(dirname, name) : name; + if (entry instanceof Directory) { + yield* arrayFrom(iteratePatchWorker(file, entry.files)); + } + else if (entry instanceof File) { + const content = typeof entry.data === "string" ? entry.data : entry.data.toString("utf8"); + yield new documents.TextDocument(file, content); + } + } +} diff --git a/external-declarations/src/test-runner/tsc-infrastructure/vpath.ts b/external-declarations/src/test-runner/tsc-infrastructure/vpath.ts new file mode 100644 index 0000000000000..f7a651e6fa554 --- /dev/null +++ b/external-declarations/src/test-runner/tsc-infrastructure/vpath.ts @@ -0,0 +1,349 @@ +import { Path } from "typescript"; +import { changeAnyExtension, comparePaths, comparePathsCaseInsensitive, comparePathsCaseSensitive, getAnyExtensionFromPath, getBaseFileName, getDirectoryPath, getPathComponents, getPathComponentsRelativeTo, getPathFromPathComponents, getRelativePathFromDirectory, isDiskPathRoot, isRootedDiskPath, reducePathComponents, resolvePath } from "../../compiler/path-utils"; +import { CharacterCodes } from "../../compiler/types"; +import { hasJSFileExtension, hasTSFileExtension, isDeclarationFileName } from "../../compiler/utils"; +import * as vfs from './vfs' + +/** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + * + * @internal + */ +export const directorySeparator = "/"; +/** @internal */ +export const altDirectorySeparator = "\\"; +const urlSchemeSeparator = "://"; +const backslashRegExp = /\\/g; +export const sep = directorySeparator; + + + +/** + * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. + * + * ```ts + * // Non-rooted + * combinePaths("path", "to", "file.ext") === "path/to/file.ext" + * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext" + * // POSIX + * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext" + * combinePaths("/path", "/to", "file.ext") === "/to/file.ext" + * // DOS + * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext" + * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext" + * // URL + * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext" + * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext" + * ``` + * + * @internal + */ +export function combine(path: string, ...paths: (string | undefined)[]): string { + if (path) path = normalizeSlashes(path); + for (let relativePath of paths) { + if (!relativePath) continue; + relativePath = normalizeSlashes(relativePath); + if (!path || getRootLength(relativePath) !== 0) { + path = relativePath; + } + else { + path = ensureTrailingDirectorySeparator(path) + relativePath; + } + } + return path; +} + +/** + * Normalize path separators, converting `\` into `/`. + * + * @internal + */ +export function normalizeSlashes(path: string): string { + return path.indexOf("\\") !== -1 + ? path.replace(backslashRegExp, directorySeparator) + : path; +} + + +/** + * Adds a trailing directory separator to a path, if it does not already have one. + * + * ```ts + * ensureTrailingDirectorySeparator("/path/to/file.ext") === "/path/to/file.ext/" + * ensureTrailingDirectorySeparator("/path/to/file.ext/") === "/path/to/file.ext/" + * ``` + * + * @internal + */ +export function ensureTrailingDirectorySeparator(path: Path): Path; +/** @internal */ +export function ensureTrailingDirectorySeparator(path: string): string; +/** @internal */ +export function ensureTrailingDirectorySeparator(path: string) { + if (!hasTrailingDirectorySeparator(path)) { + return path + directorySeparator; + } + + return path; +} + +/** + * Determines whether a path has a trailing separator (`/` or `\\`). + * + * @internal + */ +export function hasTrailingDirectorySeparator(path: string) { + return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); +} +/** + * Determines whether a charCode corresponds to `/` or `\`. + * + * @internal + */ +export function isAnyDirectorySeparator(charCode: number): boolean { + return charCode === CharacterCodes.slash || charCode === CharacterCodes.backslash; +} + + +/** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * + * For example: + * ```ts + * getRootLength("a") === 0 // "" + * getRootLength("/") === 1 // "/" + * getRootLength("c:") === 2 // "c:" + * getRootLength("c:d") === 0 // "" + * getRootLength("c:/") === 3 // "c:/" + * getRootLength("c:\\") === 3 // "c:\\" + * getRootLength("//server") === 7 // "//server" + * getRootLength("//server/share") === 8 // "//server/" + * getRootLength("\\\\server") === 7 // "\\\\server" + * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" + * getRootLength("file:///path") === 8 // "file:///" + * getRootLength("file:///c:") === 10 // "file:///c:" + * getRootLength("file:///c:d") === 8 // "file:///" + * getRootLength("file:///c:/path") === 11 // "file:///c:/" + * getRootLength("file://server") === 13 // "file://server" + * getRootLength("file://server/path") === 14 // "file://server/" + * getRootLength("http://server") === 13 // "http://server" + * getRootLength("http://server/path") === 14 // "http://server/" + * ``` + * + * @internal + */ +export function getRootLength(path: string) { + const rootLength = getEncodedRootLength(path); + return rootLength < 0 ? ~rootLength : rootLength; +} + +/** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * If the root is part of a URL, the twos-complement of the root length is returned. + */ +function getEncodedRootLength(path: string): number { + if (!path) return 0; + const ch0 = path.charCodeAt(0); + + // POSIX or UNC + if (ch0 === CharacterCodes.slash || ch0 === CharacterCodes.backslash) { + if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") + + const p1 = path.indexOf(ch0 === CharacterCodes.slash ? directorySeparator : altDirectorySeparator, 2); + if (p1 < 0) return path.length; // UNC: "//server" or "\\server" + + return p1 + 1; // UNC: "//server/" or "\\server\" + } + + // DOS + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === CharacterCodes.colon) { + const ch2 = path.charCodeAt(2); + if (ch2 === CharacterCodes.slash || ch2 === CharacterCodes.backslash) return 3; // DOS: "c:/" or "c:\" + if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") + } + + // URL + const schemeEnd = path.indexOf(urlSchemeSeparator); + if (schemeEnd !== -1) { + const authorityStart = schemeEnd + urlSchemeSeparator.length; + const authorityEnd = path.indexOf(directorySeparator, authorityStart); + if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" + // For local "file" URLs, include the leading DOS volume (if present). + // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a + // special case interpreted as "the machine from which the URL is being interpreted". + const scheme = path.slice(0, schemeEnd); + const authority = path.slice(authorityStart, authorityEnd); + if (scheme === "file" && (authority === "" || authority === "localhost") && + isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { + const volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); + if (volumeSeparatorEnd !== -1) { + if (path.charCodeAt(volumeSeparatorEnd) === CharacterCodes.slash) { + // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" + return ~(volumeSeparatorEnd + 1); + } + if (volumeSeparatorEnd === path.length) { + // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" + // but not "file:///c:d" or "file:///c%3ad" + return ~volumeSeparatorEnd; + } + } + } + return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" + } + return ~path.length; // URL: "file://server", "http://server" + } + + // relative + return 0; +} + +function isVolumeCharacter(charCode: number) { + return (charCode >= CharacterCodes.a && charCode <= CharacterCodes.z) || + (charCode >= CharacterCodes.A && charCode <= CharacterCodes.Z); +} + +function getFileUrlVolumeSeparatorEnd(url: string, start: number) { + const ch0 = url.charCodeAt(start); + if (ch0 === CharacterCodes.colon) return start + 1; + if (ch0 === CharacterCodes.percent && url.charCodeAt(start + 1) === CharacterCodes._3) { + const ch2 = url.charCodeAt(start + 2); + if (ch2 === CharacterCodes.a || ch2 === CharacterCodes.A) return start + 3; + } + return -1; +} + +export const dirname = getDirectoryPath; +/** +* Removes a trailing directory separator from a path, if it does not already have one. +* +* ```ts +* removeTrailingDirectorySeparator("/path/to/file.ext") === "/path/to/file.ext" +* removeTrailingDirectorySeparator("/path/to/file.ext/") === "/path/to/file.ext" +* ``` +* +* @internal +*/ +export function removeTrailingDirectorySeparator(path: Path): Path; +/** @internal */ +export function removeTrailingDirectorySeparator(path: string): string; +/** @internal */ +export function removeTrailingDirectorySeparator(path: string) { + if (hasTrailingDirectorySeparator(path)) { + return path.substr(0, path.length - 1); + } + + return path; +} +export const format = getPathFromPathComponents; +export const resolve = resolvePath; +export const compareCaseSensitive = comparePathsCaseSensitive; +export const compareCaseInsensitive = comparePathsCaseInsensitive; +export const isAbsolute = isRootedDiskPath; +export const isRoot = isDiskPathRoot; +export const parse = getPathComponents; +export const hasTrailingSeparator = hasTrailingDirectorySeparator; +export const reduce = reducePathComponents; +export const addTrailingSeparator = ensureTrailingDirectorySeparator; +export const compare = comparePaths; +export const relative = getRelativePathFromDirectory; +export const changeExtension = changeAnyExtension; +export const enum ValidationFlags { + None = 0, + + RequireRoot = 1 << 0, + RequireDirname = 1 << 1, + RequireBasename = 1 << 2, + RequireExtname = 1 << 3, + RequireTrailingSeparator = 1 << 4, + + AllowRoot = 1 << 5, + AllowDirname = 1 << 6, + AllowBasename = 1 << 7, + AllowExtname = 1 << 8, + AllowTrailingSeparator = 1 << 9, + AllowNavigation = 1 << 10, + AllowWildcard = 1 << 11, + + /** Path must be a valid directory root */ + Root = RequireRoot | AllowRoot | AllowTrailingSeparator, + + /** Path must be a absolute */ + Absolute = RequireRoot | AllowRoot | AllowDirname | AllowBasename | AllowExtname | AllowTrailingSeparator | AllowNavigation, + + /** Path may be relative or absolute */ + RelativeOrAbsolute = AllowRoot | AllowDirname | AllowBasename | AllowExtname | AllowTrailingSeparator | AllowNavigation, + + /** Path may only be a filename */ + Basename = RequireBasename | AllowExtname, +} + +export function validate(path: string, flags: ValidationFlags = ValidationFlags.RelativeOrAbsolute) { + const components = parse(path); + const trailing = hasTrailingSeparator(path); + if (!validateComponents(components, flags, trailing)) throw vfs.createIOError("ENOENT"); + return components.length > 1 && trailing ? format(reduce(components)) + sep : format(reduce(components)); +} + + +const invalidRootComponentRegExp = /^(?!(\/|\/\/\w+\/|[a-zA-Z]:\/?|)$)/; +const invalidNavigableComponentRegExp = /[:*?"<>|]/; +const invalidNavigableComponentWithWildcardsRegExp = /[:"<>|]/; +const invalidNonNavigableComponentRegExp = /^\.{1,2}$|[:*?"<>|]/; +const invalidNonNavigableComponentWithWildcardsRegExp = /^\.{1,2}$|[:"<>|]/; +const extRegExp = /\.\w+$/; +function validateComponents(components: string[], flags: ValidationFlags, hasTrailingSeparator: boolean) { + const hasRoot = !!components[0]; + const hasDirname = components.length > 2; + const hasBasename = components.length > 1; + const hasExtname = hasBasename && extRegExp.test(components[components.length - 1]); + const invalidComponentRegExp = flags & ValidationFlags.AllowNavigation + ? flags & ValidationFlags.AllowWildcard ? invalidNavigableComponentWithWildcardsRegExp : invalidNavigableComponentRegExp + : flags & ValidationFlags.AllowWildcard ? invalidNonNavigableComponentWithWildcardsRegExp : invalidNonNavigableComponentRegExp; + + // Validate required components + if (flags & ValidationFlags.RequireRoot && !hasRoot) return false; + if (flags & ValidationFlags.RequireDirname && !hasDirname) return false; + if (flags & ValidationFlags.RequireBasename && !hasBasename) return false; + if (flags & ValidationFlags.RequireExtname && !hasExtname) return false; + if (flags & ValidationFlags.RequireTrailingSeparator && !hasTrailingSeparator) return false; + + // Required components indicate allowed components + if (flags & ValidationFlags.RequireRoot) flags |= ValidationFlags.AllowRoot; + if (flags & ValidationFlags.RequireDirname) flags |= ValidationFlags.AllowDirname; + if (flags & ValidationFlags.RequireBasename) flags |= ValidationFlags.AllowBasename; + if (flags & ValidationFlags.RequireExtname) flags |= ValidationFlags.AllowExtname; + if (flags & ValidationFlags.RequireTrailingSeparator) flags |= ValidationFlags.AllowTrailingSeparator; + + // Validate disallowed components + if (~flags & ValidationFlags.AllowRoot && hasRoot) return false; + if (~flags & ValidationFlags.AllowDirname && hasDirname) return false; + if (~flags & ValidationFlags.AllowBasename && hasBasename) return false; + if (~flags & ValidationFlags.AllowExtname && hasExtname) return false; + if (~flags & ValidationFlags.AllowTrailingSeparator && hasTrailingSeparator) return false; + + // Validate component strings + if (invalidRootComponentRegExp.test(components[0])) return false; + for (let i = 1; i < components.length; i++) { + if (invalidComponentRegExp.test(components[i])) return false; + } + + return true; +} + +export function isDeclaration(path: string) { + return isDeclarationFileName(path); +} + +export const isTypeScript = hasTSFileExtension; +export const isJavaScript = hasJSFileExtension; +export const extname = getAnyExtensionFromPath; +export const basename = getBaseFileName; + +export function isSourceMap(path: string) { + return extname(path, ".map", /*ignoreCase*/ false).length > 0; +} +export function isTsConfigFile(path: string): boolean { + return path.indexOf("tsconfig") !== -1 && path.indexOf("json") !== -1; +} diff --git a/external-declarations/src/test-runner/utils.ts b/external-declarations/src/test-runner/utils.ts new file mode 100644 index 0000000000000..545ee278c8784 --- /dev/null +++ b/external-declarations/src/test-runner/utils.ts @@ -0,0 +1,93 @@ + +import * as path from 'path' +import * as ts from 'typescript' +import { compileFiles, TestFile, Utils } from "./tsc-infrastructure/compiler-run"; +import * as TestCaseParser from "./tsc-infrastructure/test-file-parser"; +import * as fsp from 'fs/promises' +import { getDeclarationExtension, isDeclarationFile, isJavaScriptFile, isJSONFile, isSourceMapFile } from '../compiler/path-utils'; +import { changeExtension } from './tsc-infrastructure/vpath'; +import * as vpath from "./tsc-infrastructure/vpath"; +import { libs } from './tsc-infrastructure/options'; +import { ModuleKind } from 'typescript'; +import { transformFile } from '../compiler/transform-file'; + +export function swapLocation(file: string, changed: string, extension: string | undefined = ".d.ts") { + const parentDir = path.dirname(path.dirname(file)); + let baseFile = path.basename(file) + if (extension) { + const existingExtension = path.extname(file); + baseFile = baseFile.substring(0, baseFile.length - existingExtension.length) + extension; + } + return path.join(parentDir, changed, baseFile); +} + +export interface FileContent { + content: string, + fileName: string +} + +export async function loadTestCase(fileName: string) { + const rawText = await fsp.readFile(fileName, { encoding: "utf-8" }); + const test = { + content: Utils.removeByteOrderMark(rawText), + file: fileName, + } + return Object.assign(TestCaseParser.makeUnitsFromTest(test.content, test.file), { + BOM: rawText.substring(0, Utils.getByteOrderMarkLength(rawText)) + }); +} +export function runTypeScript(caseData: TestCaseParser.TestCaseContent, settings: ts.CompilerOptions): FileContent[] { + function createHarnessTestFile(lastUnit: TestCaseParser.TestUnitData): TestFile { + return { unitName: lastUnit.name, content: lastUnit.content, fileOptions: lastUnit.fileOptions }; + } + + const toBeCompiled = caseData.testUnitData.map(unit => { + return createHarnessTestFile(unit); + }); + + const result = compileFiles(toBeCompiled, [], { + declaration: "true", + isolatedDeclarations: "true", + removeComments: "false", + }, settings, undefined); + + return caseData.testUnitData + .filter(isRelevantTestFile) + .map(file => { + const declarationFile = changeExtension(file.name, getDeclarationExtension(file.name)); + const resolvedDeclarationFile = vpath.resolve(result.vfs.cwd(), declarationFile); + const declaration = result.dts.get(resolvedDeclarationFile) + return { + content: declaration?.text ?? "", + fileName: declarationFile, + }; + }) +} +export function isRelevantTestFile(f: TestCaseParser.TestUnitData) { + return !isDeclarationFile(f.name) && !isJavaScriptFile(f.name) && !isJSONFile(f.name) && !isSourceMapFile(f.name) && f.content !== undefined +} + + +export function runIsolated(caseData: TestCaseParser.TestCaseContent, libFiles: string[], settings: ts.CompilerOptions): FileContent[] { + const toSrc = (n: string) => vpath.combine('/src', n); + const projectFiles = [...caseData.testUnitData.map(o => toSrc(o.name)), ...libFiles]; + + const packageJson = caseData.testUnitData.find(f => f.name === "/package.json"); + let packageResolution: ts.ResolutionMode = ts.ModuleKind.CommonJS + if (packageJson) { + packageResolution = JSON.parse(packageJson.content)?.type === "module" ? ModuleKind.ESNext : ModuleKind.CommonJS + } + + const results = caseData.testUnitData + .filter(isRelevantTestFile) + .map(file => { + const declaration = transformFile(toSrc(file.name), Utils.removeByteOrderMark(file.content), projectFiles, libs, settings, packageResolution) + return { + content: declaration.code, + fileName: changeExtension(file.name, getDeclarationExtension(file.name)), + }; + }) + return results; +} + + diff --git a/external-declarations/src/tsconfig.json b/external-declarations/src/tsconfig.json new file mode 100644 index 0000000000000..26012c4a16ff9 --- /dev/null +++ b/external-declarations/src/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + + "pretty": true, + "lib": ["es2018", "DOM"], + "target": "es2018", + "module": "CommonJS", + "moduleResolution": "node", + + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "composite": true, + + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictPropertyInitialization": true, + + "skipLibCheck": true, + + "alwaysStrict": true, + "preserveConstEnums": true, + "outDir": "../build" + } +} \ No newline at end of file diff --git a/external-declarations/src/utils/cli-parser.ts b/external-declarations/src/utils/cli-parser.ts new file mode 100644 index 0000000000000..56f0fd0073ee0 --- /dev/null +++ b/external-declarations/src/utils/cli-parser.ts @@ -0,0 +1,140 @@ + + +export type ArgTypeParser = (name: string, value: string | undefined, existingValue: T | undefined) => T +function mustNotExist(fn: ArgTypeParser): ArgTypeParser { + return (name, value, existingValue) => { + if (existingValue) { + throw new Error(`Parameter ${name} was specified multiple times. Values ${existingValue}, ${value}`); + } + return fn(name, value, existingValue); + } +} +export const ArgType = { + String: () => mustNotExist((name, value) => { + if (value) { + return value; + } + throw new Error(`String value was not specified for ${name}`); + }), + Boolean: () => mustNotExist((name, value) => { + if (value === undefined) { + return true; + } + if (value.toLowerCase() === "false") { + return false; + } + if (value.toLowerCase() === "true") { + return true; + } + throw new Error(`Invalid Boolean Value ${value} for ${name}`); + }), + Enum: (...values: T[]) => mustNotExist((name, value,) => { + if (values.includes(value as T)) { + return value as T; + } + throw new Error(`Invalid Enum value, Expected one of ${values.join(",")}`); + }), + Number: () => mustNotExist((name, value) => { + if (value && !Number.isNaN(+value)) { + return +value; + } + throw new Error(`Invalid Number value, found ${value}`); + }), + StringArray: () => (name, value, existingValue: string[] | undefined) => { + existingValue ??= []; + if (value) { + existingValue.push(value) + return existingValue; + } + throw new Error(`String value was not specified for ${name}`); + }, +} satisfies Record ArgTypeParser> + + +type ParserConfiguration = Record | { + type: ArgTypeParser, + required?: V, + description: string, +}> +type ParsedValue> = { + [P in keyof T]: + T[P] extends ArgTypeParser ? A | undefined : + T[P] extends { + type: ArgTypeParser, + required?: infer R + } ? R extends true ? A : A | undefined : never +} + +export function parserConfiguration>(config:T) { + return config; +} +export function parseArgs>(args: string[], types: T): { + value: ParsedValue, + diagnostics: string[], + usage: () => string + printUsageOnErrors: () => void; +} { + const config: Record = {} + const diagnostics: string[] = [] + function parseArgument(name: string, value: string | undefined) { + const existingValue = config[name] + const parser = types[name]; + if(!parser) { + diagnostics.push(`Parameter ${name} was unexpected`) + return; + } + const parserFn = typeof parser === "function" ? parser: parser.type; + try { + const newValue = parserFn(name, value, existingValue); + config[name] = newValue; + } catch(e) { + if(e instanceof Error) { + diagnostics.push(e.message); + } + throw e; + } + } + for (const arg of args) { + const named = /--(?.*)=(?.*)/.exec(arg); + if (named) { + parseArgument(named.groups?.name!, named.groups?.value); + } + else { + const flagParam =/--(?.*)/.exec(arg); + if (flagParam) { + parseArgument(flagParam.groups?.name!, undefined); + } else { + parseArgument('default', arg); + } + } + } + + for(const key of Object.keys(types)) { + const cfg = types[key]; + if(!(key in config) && 'required' in cfg && cfg.required) { + diagnostics.push(`Parameters ${key} is required`); + } + } + function usage() { + return Object.entries(types) + .map(([name, v]) => ({ + name, + ...(typeof v === "object" ? v: { }) + })) + .filter(o => !!o.description) + .map(({ name, description, required }) => `--${name} \t ${description} \t ${required? "required": ""}`) + .join("\n"); + } + return { + value: config as any, + diagnostics, + usage, + printUsageOnErrors() { + if(diagnostics.length) { + diagnostics.forEach(s => console.log(s)); + console.log(usage()); + process.exit(); + } + }, + } +} diff --git a/external-declarations/src/utils/fs-utils.ts b/external-declarations/src/utils/fs-utils.ts new file mode 100644 index 0000000000000..2ea35b0dc0768 --- /dev/null +++ b/external-declarations/src/utils/fs-utils.ts @@ -0,0 +1,119 @@ +import * as fs from 'fs' +import * as fsp from 'fs/promises' +import { flatten, stableSort, compareStringsCaseSensitive } from '../compiler/lang-utils'; +import { normalizePath, createGetCanonicalFileName, combinePaths } from '../compiler/path-utils'; +import { FileSystemEntries } from '../test-runner/tsc-infrastructure/vfs'; + +const cache: Record = {} +export async function ensureDir(dirName: string) { + + const exists = cache[dirName] ?? + (await fsp.access(dirName).then(() => true, () => false)); + + if (!exists) { + await fsp.mkdir(dirName, { recursive: true }); + cache[dirName] = true; + } +} +let writeQueue = [0, 0, 0, 0, 0].map(() => Promise.resolve()); +let writeQueueIndex = 0; + +export function addToQueue(fn: () => Promise) { + const index = writeQueueIndex++ % writeQueue.length; + writeQueue[index] = writeQueue[index].then(() => { + return fn(); + }); +} + +export function flushQueue() { + return Promise.all(writeQueue); +} + + +/** + * @param path directory of the tsconfig.json + * + * @internal + */ +export function readAllFiles(path: string, regex: RegExp): string[] { + path = normalizePath(path); + + // Associate an array of results with each include regex. This keeps results in order of the "include" order. + // If there are no "includes", then just put everything in results[0]. + const results: string[] = []; + const visited = new Map(); + const toCanonical = createGetCanonicalFileName(false); + + visitDirectory(path, path); + + return flatten(results); + + function visitDirectory(path: string, absolutePath: string) { + const canonicalPath = toCanonical(absolutePath); + if (visited.has(canonicalPath)) return; + visited.set(canonicalPath, true); + const { files, directories } = getAccessibleFileSystemEntries(path); + + for (const current of stableSort(files, compareStringsCaseSensitive)) { + const name = combinePaths(path, current); + if (!regex.exec(name)) continue; + const absoluteName = combinePaths(absolutePath, current); + results.push(absoluteName); + } + for (const current of stableSort(directories, compareStringsCaseSensitive)) { + const name = combinePaths(path, current); + const absoluteName = combinePaths(absolutePath, current); + visitDirectory(name, absoluteName); + } + } +} + +function getAccessibleFileSystemEntries(path: string): FileSystemEntries { + try { + const entries = fs.readdirSync(path || ".", { withFileTypes: true }); + const files: string[] = []; + const directories: string[] = []; + for (const dirent of entries) { + // withFileTypes is not supported before Node 10.10. + const entry = typeof dirent === "string" ? dirent : dirent.name; + + // This is necessary because on some file system node fails to exclude + // "." and "..". See https://github.com/nodejs/node/issues/4002 + if (entry === "." || entry === "..") { + continue; + } + + let stat: any; + if (typeof dirent === "string" || dirent.isSymbolicLink()) { + const name = combinePaths(path, entry); + + try { + stat = fs.statSync(name); + if (!stat) { + continue; + } + } + catch (e) { + continue; + } + } + else { + stat = dirent; + } + + if (stat.isFile()) { + files.push(entry); + } + else if (stat.isDirectory()) { + directories.push(entry); + } + } + files.sort(); + directories.sort(); + return { files, directories }; + } + catch (e) { + return { files: [], directories: [] }; + } +} + diff --git a/external-declarations/tests/expected/class-all.d.ts b/external-declarations/tests/expected/class-all.d.ts new file mode 100644 index 0000000000000..af5d82e96cbd1 --- /dev/null +++ b/external-declarations/tests/expected/class-all.d.ts @@ -0,0 +1,8 @@ +export declare class Person { + age: number; + greet(): void; + overloaded(a: number): number; + overloaded(a: string): string; + get ageAccessor(): number; + set ageAccessor(value: number); +} diff --git a/external-declarations/tests/expected/const-var-init.d.ts b/external-declarations/tests/expected/const-var-init.d.ts new file mode 100644 index 0000000000000..e0e43abe26758 --- /dev/null +++ b/external-declarations/tests/expected/const-var-init.d.ts @@ -0,0 +1 @@ +export declare const test = 1; diff --git a/external-declarations/tests/expected/const-var.d.ts b/external-declarations/tests/expected/const-var.d.ts new file mode 100644 index 0000000000000..298be4f0ff82b --- /dev/null +++ b/external-declarations/tests/expected/const-var.d.ts @@ -0,0 +1 @@ +export declare const test: number; diff --git a/external-declarations/tests/expected/export-default.d.ts b/external-declarations/tests/expected/export-default.d.ts new file mode 100644 index 0000000000000..83a998ddc9e1c --- /dev/null +++ b/external-declarations/tests/expected/export-default.d.ts @@ -0,0 +1,2 @@ +declare const value: number; +export default value; diff --git a/external-declarations/tests/expected/functions.d.ts b/external-declarations/tests/expected/functions.d.ts new file mode 100644 index 0000000000000..3f00542289412 --- /dev/null +++ b/external-declarations/tests/expected/functions.d.ts @@ -0,0 +1,8 @@ +declare function test(a: string): number; +export declare const testAlias: typeof test; +export declare function testOptional(a: string, b?: string): number; +export declare function testDefault(a: string, b?: string): number; +export declare function testRest(...a: string[]): number; +export declare function testTuple(...a: [string, string]): number; +export declare function testTupleRest(...a: [string, string] | [number, number]): number; +export {}; diff --git a/external-declarations/tests/expected/global.d.ts b/external-declarations/tests/expected/global.d.ts new file mode 100644 index 0000000000000..da3cfbdf134e2 --- /dev/null +++ b/external-declarations/tests/expected/global.d.ts @@ -0,0 +1,10 @@ +declare class Cell { +} +declare class Ship { + isSunk: boolean; +} +declare class Board { + ships: Ship[]; + cells: Cell[]; + private allShipsSunk; +} diff --git a/external-declarations/tests/expected/imports.d.ts b/external-declarations/tests/expected/imports.d.ts new file mode 100644 index 0000000000000..723411f835eb1 --- /dev/null +++ b/external-declarations/tests/expected/imports.d.ts @@ -0,0 +1,7 @@ +import { Person } from './class-all'; +import * as fns from './functions'; +import def from './export-default'; +export declare let person: Person; +export declare const nr: number; +export declare const fff: typeof fns; +export default def; diff --git a/external-declarations/tests/expected/interface.d.ts b/external-declarations/tests/expected/interface.d.ts new file mode 100644 index 0000000000000..0fbc0907b545b --- /dev/null +++ b/external-declarations/tests/expected/interface.d.ts @@ -0,0 +1,6 @@ +export interface I { + n: number; + o: { + s: string; + }; +} diff --git a/external-declarations/tests/expected/let-var.d.ts b/external-declarations/tests/expected/let-var.d.ts new file mode 100644 index 0000000000000..5d422b6d153a5 --- /dev/null +++ b/external-declarations/tests/expected/let-var.d.ts @@ -0,0 +1 @@ +export declare let test: number; diff --git a/external-declarations/tests/expected/transitive.d.ts b/external-declarations/tests/expected/transitive.d.ts new file mode 100644 index 0000000000000..59032b911a1c4 --- /dev/null +++ b/external-declarations/tests/expected/transitive.d.ts @@ -0,0 +1,5 @@ +import { Person } from "./class-all"; +type Q = P; +type P = Person; +export type D = Q; +export {}; diff --git a/external-declarations/tests/expected/tsconfig.json b/external-declarations/tests/expected/tsconfig.json new file mode 100644 index 0000000000000..5c0ac4c34a20b --- /dev/null +++ b/external-declarations/tests/expected/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strict": true + } +} \ No newline at end of file diff --git a/external-declarations/tests/expected/type-aliases.d.ts b/external-declarations/tests/expected/type-aliases.d.ts new file mode 100644 index 0000000000000..b52ed36649b9d --- /dev/null +++ b/external-declarations/tests/expected/type-aliases.d.ts @@ -0,0 +1,8 @@ +type PersonType = { + age: string; +}; +type Id = { + [P in keyof T]: T[P]; +}; +export type P = Id; +export {}; diff --git a/external-declarations/tests/source/.gitignore b/external-declarations/tests/source/.gitignore new file mode 100644 index 0000000000000..a6c7c2852d068 --- /dev/null +++ b/external-declarations/tests/source/.gitignore @@ -0,0 +1 @@ +*.js diff --git a/external-declarations/tests/source/binder/conditionalTypeAliasing.ts b/external-declarations/tests/source/binder/conditionalTypeAliasing.ts new file mode 100644 index 0000000000000..36a97e3979bda --- /dev/null +++ b/external-declarations/tests/source/binder/conditionalTypeAliasing.ts @@ -0,0 +1,36 @@ +type TA = string; +type UA = string; +export type Conditional = UA extends infer TA ? TA: never; + + +type TF = string; +type UF = string; +export function test(o: UF extends infer TF ? TF: never): UF extends infer TF ? TF: never { + return null! +} + +type TC = string; +type UC = string; +export class C { + member!: UC extends infer TC ? TC: never + get accessor(): UC extends infer TC ? TC: never { + return null! + } + set accessor(value: UC extends infer TC ? TC: never) { + + } + constructor(p: UC extends infer TC ? TC: never) { + return null!; + } + method(p: UC extends infer TC ? TC: never): UC extends infer TC ? TC: never { + return null!; + } +} + +type TI = string; +type UI = string; +export interface I { + member: UI extends infer TI ? TI: never + method(p: UI extends infer TI ? TI: never): UI extends infer TI ? TI: never; + new (p: UI extends infer TI ? TI: never): UI extends infer TI ? TI: never; +} \ No newline at end of file diff --git a/external-declarations/tests/source/binder/default-class-symbol.ts b/external-declarations/tests/source/binder/default-class-symbol.ts new file mode 100644 index 0000000000000..ffc46996a8233 --- /dev/null +++ b/external-declarations/tests/source/binder/default-class-symbol.ts @@ -0,0 +1,5 @@ +export default class Class { + parent!: Class; +} + +export const instance: Class = new Class(); \ No newline at end of file diff --git a/external-declarations/tests/source/binder/default-function-symbol.ts b/external-declarations/tests/source/binder/default-function-symbol.ts new file mode 100644 index 0000000000000..60b729d25164b --- /dev/null +++ b/external-declarations/tests/source/binder/default-function-symbol.ts @@ -0,0 +1,5 @@ +export default function foo(): typeof foo { + return foo; +} + +export const instance: typeof foo = foo; \ No newline at end of file diff --git a/external-declarations/tests/source/binder/enum-members-aliasing.ts b/external-declarations/tests/source/binder/enum-members-aliasing.ts new file mode 100644 index 0000000000000..c25be6b680918 --- /dev/null +++ b/external-declarations/tests/source/binder/enum-members-aliasing.ts @@ -0,0 +1,5 @@ +const X = 1; +export const enum E { + X = 1, + Y = X +} diff --git a/external-declarations/tests/source/binder/local-and-export-symbols.ts b/external-declarations/tests/source/binder/local-and-export-symbols.ts new file mode 100644 index 0000000000000..499e6fc78f440 --- /dev/null +++ b/external-declarations/tests/source/binder/local-and-export-symbols.ts @@ -0,0 +1,5 @@ +export interface I { +} + +const I = 1; +export const O: I = {} \ No newline at end of file diff --git a/external-declarations/tests/source/binder/parameterAliasing.ts b/external-declarations/tests/source/binder/parameterAliasing.ts new file mode 100644 index 0000000000000..78c94c75d2728 --- /dev/null +++ b/external-declarations/tests/source/binder/parameterAliasing.ts @@ -0,0 +1,4 @@ +const p: string =""; +export function test(p: number, r: typeof p): UF extends infer TF ? TF: typeof p { + return null! +} \ No newline at end of file diff --git a/external-declarations/tests/source/binder/re-exported-import-visibility.ts b/external-declarations/tests/source/binder/re-exported-import-visibility.ts new file mode 100644 index 0000000000000..7a5f57dc7121f --- /dev/null +++ b/external-declarations/tests/source/binder/re-exported-import-visibility.ts @@ -0,0 +1,8 @@ +// x0.d.ts +export declare let a: invalid; + +// x.d.ts +declare module "./observable" { + // import { a } from "./x0"; + export { a } from "./x0"; +} \ No newline at end of file diff --git a/external-declarations/tests/source/class-all.ts b/external-declarations/tests/source/class-all.ts new file mode 100644 index 0000000000000..9d4f35f18a9bd --- /dev/null +++ b/external-declarations/tests/source/class-all.ts @@ -0,0 +1,19 @@ +export class Person { + age: number = 1; + greet(): void { + console.log("Hi") + } + + overloaded(a: number): number; + overloaded(a: string): string; + overloaded(a: any): any{ + return a; + } + + get ageAccessor(): number { + return this.age; + } + set ageAccessor(value: number) { + this.age = value; + } +} \ No newline at end of file diff --git a/external-declarations/tests/source/const-var-init.ts b/external-declarations/tests/source/const-var-init.ts new file mode 100644 index 0000000000000..873e758025b50 --- /dev/null +++ b/external-declarations/tests/source/const-var-init.ts @@ -0,0 +1 @@ +export const test = 1; diff --git a/external-declarations/tests/source/const-var.ts b/external-declarations/tests/source/const-var.ts new file mode 100644 index 0000000000000..42a1cdeda0cc4 --- /dev/null +++ b/external-declarations/tests/source/const-var.ts @@ -0,0 +1 @@ +export const test: number = 0; diff --git a/external-declarations/tests/source/export-default.ts b/external-declarations/tests/source/export-default.ts new file mode 100644 index 0000000000000..9668f69f682de --- /dev/null +++ b/external-declarations/tests/source/export-default.ts @@ -0,0 +1,2 @@ +const value: number = 10; +export default value \ No newline at end of file diff --git a/external-declarations/tests/source/functions.ts b/external-declarations/tests/source/functions.ts new file mode 100644 index 0000000000000..dfbbf4c867322 --- /dev/null +++ b/external-declarations/tests/source/functions.ts @@ -0,0 +1,29 @@ + + +function test(a: string): number { + return 0; +} +export const testAlias: typeof test = test; + +export function testOptional(a: string, b?: string): number { + return 0; +} + +export function testDefault(a: string, b: string = ""): number { + return 0; +} + + +export function testRest(...a: string[]): number { + return 0; +} + +export function testTuple(...a: [string, string]): number { + return 0; +} + +export function testTupleRest(...a: + | [string, string] + | [number, number]): number { + return 0; +} \ No newline at end of file diff --git a/external-declarations/tests/source/global.ts b/external-declarations/tests/source/global.ts new file mode 100644 index 0000000000000..e56cd849ba20b --- /dev/null +++ b/external-declarations/tests/source/global.ts @@ -0,0 +1,15 @@ +class Cell { +} + +class Ship { + isSunk: boolean; +} + +class Board { + ships: Ship[]; + cells: Cell[]; + + private allShipsSunk() { + return this.ships.every(function (val) { return val.isSunk; }); + } +} \ No newline at end of file diff --git a/external-declarations/tests/source/imports.ts b/external-declarations/tests/source/imports.ts new file mode 100644 index 0000000000000..0f5ac62055fbd --- /dev/null +++ b/external-declarations/tests/source/imports.ts @@ -0,0 +1,12 @@ +import { Person } from './class-all'; +import * as fns from './functions'; +import * as fns2 from './functions'; +import def from './export-default'; + + +export let person: Person = new Person; +export const nr: number = fns2.testAlias("1"); +export const fff: typeof fns = fns; +export default def; + + diff --git a/external-declarations/tests/source/interface.ts b/external-declarations/tests/source/interface.ts new file mode 100644 index 0000000000000..88d0e45286812 --- /dev/null +++ b/external-declarations/tests/source/interface.ts @@ -0,0 +1,6 @@ +export interface I { + n: number; + o: { + s: string + } +} \ No newline at end of file diff --git a/external-declarations/tests/source/let-var.ts b/external-declarations/tests/source/let-var.ts new file mode 100644 index 0000000000000..44e8ffc615312 --- /dev/null +++ b/external-declarations/tests/source/let-var.ts @@ -0,0 +1 @@ +export let test: number = 0; diff --git a/external-declarations/tests/source/private-members-typeof.ts b/external-declarations/tests/source/private-members-typeof.ts new file mode 100644 index 0000000000000..4387ee66df7a0 --- /dev/null +++ b/external-declarations/tests/source/private-members-typeof.ts @@ -0,0 +1,4 @@ +class Test { + #foo = 1 + #bar: typeof this.#foo = 1; +} \ No newline at end of file diff --git a/external-declarations/tests/source/transitive.ts b/external-declarations/tests/source/transitive.ts new file mode 100644 index 0000000000000..e599dad981578 --- /dev/null +++ b/external-declarations/tests/source/transitive.ts @@ -0,0 +1,4 @@ +import { Person } from "./class-all"; +type Q = P; +type P = Person; +export type D = Q; \ No newline at end of file diff --git a/external-declarations/tests/source/tsconfig.json b/external-declarations/tests/source/tsconfig.json new file mode 100644 index 0000000000000..587ba1c506cf8 --- /dev/null +++ b/external-declarations/tests/source/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "strict": true, + "target": "ESNext" + } +} \ No newline at end of file diff --git a/external-declarations/tests/source/type-aliases.ts b/external-declarations/tests/source/type-aliases.ts new file mode 100644 index 0000000000000..db7efb5b0b514 --- /dev/null +++ b/external-declarations/tests/source/type-aliases.ts @@ -0,0 +1,13 @@ +type PersonType = { + age: string; +} + +type Id = { + [P in keyof T]: T[P] +} + +export type P = Id + +function x() { + return 1; +} \ No newline at end of file diff --git a/external-declarations/tests/source/unicode-chars.ts b/external-declarations/tests/source/unicode-chars.ts new file mode 100644 index 0000000000000..d325ca925d118 --- /dev/null +++ b/external-declarations/tests/source/unicode-chars.ts @@ -0,0 +1,3 @@ +// @target: es2015 +// @filename: extendedEscapesForAstralsInVarsAndClasses.ts +export var _𐊧 = "" \ No newline at end of file diff --git a/package.json b/package.json index 016f50cd59a55..d2cb6f0854a57 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "type": "git", "url": "https://github.com/Microsoft/TypeScript.git" }, - "main": "./lib/typescript.js", - "typings": "./lib/typescript.d.ts", + "main": "./built/local/typescript.js", + "typings": "./built/local/typescript.d.ts", "bin": { "tsc": "./bin/tsc", "tsserver": "./bin/tsserver"