mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge remote-tracking branch 'origin/main' into release-4.8
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
sandersn
|
||||
elibarzilay
|
||||
weswigham
|
||||
andrewbranch
|
||||
RyanCavanaugh
|
||||
sheetalkamat
|
||||
orta
|
||||
rbuckton
|
||||
ahejlsberg
|
||||
amcasey
|
||||
jessetrinity
|
||||
minestarks
|
||||
armanio123
|
||||
gabritto
|
||||
jakebailey
|
||||
DanielRosenwasser
|
||||
navya9singh
|
||||
|
||||
@@ -31,10 +31,6 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
check-latest: true
|
||||
- name: Remove existing TypeScript
|
||||
run: |
|
||||
npm uninstall typescript --no-save
|
||||
npm uninstall tslint --no-save
|
||||
- run: npm ci
|
||||
|
||||
# Re: https://github.com/actions/setup-node/pull/125
|
||||
|
||||
@@ -12,10 +12,6 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v3
|
||||
- name: Remove existing TypeScript
|
||||
run: |
|
||||
npm uninstall typescript --no-save
|
||||
npm uninstall tslint --no-save
|
||||
- name: npm install and test
|
||||
run: |
|
||||
npm ci
|
||||
|
||||
@@ -16,13 +16,14 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 14
|
||||
node-version: 16
|
||||
|
||||
- name: Configure git and update package-lock.json
|
||||
run: |
|
||||
git config user.email "typescriptbot@microsoft.com"
|
||||
git config user.name "TypeScript Bot"
|
||||
npm install --package-lock-only --ignore-scripts
|
||||
rm package-lock.json
|
||||
npm install --package-lock-only --ignore-scripts # This is a no-op if package-lock.json is present.
|
||||
git add -f package-lock.json
|
||||
if git commit -m "Update package-lock.json"; then
|
||||
git push
|
||||
|
||||
@@ -148,6 +148,10 @@ The files in `lib/` are used to bootstrap compilation and usually **should not**
|
||||
|
||||
The files `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts` both represent type declarations for the DOM and are auto-generated. To make any modifications to them, you will have to direct changes to https://github.com/Microsoft/TSJS-lib-generator
|
||||
|
||||
## Documentation on TypeScript Compiler
|
||||
|
||||
If you need a head start understanding how the compiler works, or how the code in different parts of the compiler works, there is a separate repo: [TypeScript Compiler Notes](https://github.com/microsoft/TypeScript-Compiler-Notes). As the name implies, it contains notes understood by different engineers about different parts of the compiler.
|
||||
|
||||
## Running the Tests
|
||||
|
||||
To run all tests, invoke the `runtests-parallel` target using gulp:
|
||||
|
||||
Generated
+9455
-498
File diff suppressed because it is too large
Load Diff
+6
-2
@@ -28,7 +28,6 @@
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
},
|
||||
"packageManager": "npm@6.14.15",
|
||||
"devDependencies": {
|
||||
"@octokit/rest": "latest",
|
||||
"@types/chai": "latest",
|
||||
@@ -91,6 +90,9 @@
|
||||
"vinyl-sourcemaps-apply": "latest",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"overrides": {
|
||||
"es5-ext": "0.10.53"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "gulp build-eslint-rules",
|
||||
"pretest": "gulp tests",
|
||||
@@ -118,7 +120,9 @@
|
||||
"source-map-support": false,
|
||||
"inspector": false
|
||||
},
|
||||
"packageManager": "npm@8.15.0",
|
||||
"volta": {
|
||||
"node": "14.15.5"
|
||||
"node": "14.20.0",
|
||||
"npm": "8.15.0"
|
||||
}
|
||||
}
|
||||
|
||||
+7
-41
@@ -2040,41 +2040,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindObjectLiteralExpression(node: ObjectLiteralExpression) {
|
||||
const enum ElementKind {
|
||||
Property = 1,
|
||||
Accessor = 2
|
||||
}
|
||||
|
||||
if (inStrictMode && !isAssignmentTarget(node)) {
|
||||
const seen = new Map<__String, ElementKind>();
|
||||
|
||||
for (const prop of node.properties) {
|
||||
if (prop.kind === SyntaxKind.SpreadAssignment || prop.name.kind !== SyntaxKind.Identifier) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const identifier = prop.name;
|
||||
|
||||
// ECMA-262 11.1.5 Object Initializer
|
||||
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
|
||||
// IsDataDescriptor(propId.descriptor) is true.
|
||||
// b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true.
|
||||
// c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
|
||||
// d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true
|
||||
// and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
|
||||
const currentKind = prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment || prop.kind === SyntaxKind.MethodDeclaration
|
||||
? ElementKind.Property
|
||||
: ElementKind.Accessor;
|
||||
|
||||
const existingKind = seen.get(identifier.escapedText);
|
||||
if (!existingKind) {
|
||||
seen.set(identifier.escapedText, currentKind);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, InternalSymbolName.Object);
|
||||
}
|
||||
|
||||
@@ -3509,10 +3474,11 @@ namespace ts {
|
||||
|
||||
export function isExportsOrModuleExportsOrAlias(sourceFile: SourceFile, node: Expression): boolean {
|
||||
let i = 0;
|
||||
const q = [node];
|
||||
while (q.length && i < 100) {
|
||||
const q = createQueue<Expression>();
|
||||
q.enqueue(node);
|
||||
while (!q.isEmpty() && i < 100) {
|
||||
i++;
|
||||
node = q.shift()!;
|
||||
node = q.dequeue();
|
||||
if (isExportsIdentifier(node) || isModuleExportsAccessExpression(node)) {
|
||||
return true;
|
||||
}
|
||||
@@ -3520,10 +3486,10 @@ namespace ts {
|
||||
const symbol = lookupSymbolForName(sourceFile, node.escapedText);
|
||||
if (!!symbol && !!symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
|
||||
const init = symbol.valueDeclaration.initializer;
|
||||
q.push(init);
|
||||
q.enqueue(init);
|
||||
if (isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) {
|
||||
q.push(init.left);
|
||||
q.push(init.right);
|
||||
q.enqueue(init.left);
|
||||
q.enqueue(init.right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+136
-47
@@ -62,9 +62,9 @@ namespace ts {
|
||||
*/
|
||||
outSignature?: string;
|
||||
/**
|
||||
* Time when d.ts was modified
|
||||
* Name of the file whose dts was the latest to change
|
||||
*/
|
||||
dtsChangeTime: number | undefined;
|
||||
latestChangedDtsFile: string | undefined;
|
||||
}
|
||||
|
||||
export const enum BuilderFileEmit {
|
||||
@@ -112,7 +112,7 @@ namespace ts {
|
||||
/**
|
||||
* Records if change in dts emit was detected
|
||||
*/
|
||||
hasChangedEmitSignature?: boolean;
|
||||
hasChangedEmitSignature?: boolean;
|
||||
/**
|
||||
* Files pending to be emitted
|
||||
*/
|
||||
@@ -141,7 +141,7 @@ namespace ts {
|
||||
"programEmitComplete" |
|
||||
"emitSignatures" |
|
||||
"outSignature" |
|
||||
"dtsChangeTime" |
|
||||
"latestChangedDtsFile" |
|
||||
"hasChangedEmitSignature"
|
||||
> & { changedFilesSet: BuilderProgramState["changedFilesSet"] | undefined };
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace ts {
|
||||
state.outSignature = oldState?.outSignature;
|
||||
}
|
||||
state.changedFilesSet = new Set();
|
||||
state.dtsChangeTime = compilerOptions.composite ? oldState?.dtsChangeTime : undefined;
|
||||
state.latestChangedDtsFile = compilerOptions.composite ? oldState?.latestChangedDtsFile : undefined;
|
||||
|
||||
const useOldState = BuilderState.canReuseOldState(state.referencedMap, oldState);
|
||||
const oldCompilerOptions = useOldState ? oldState!.compilerOptions : undefined;
|
||||
@@ -301,7 +301,7 @@ namespace ts {
|
||||
programEmitComplete: state.programEmitComplete,
|
||||
emitSignatures: state.emitSignatures && new Map(state.emitSignatures),
|
||||
outSignature: state.outSignature,
|
||||
dtsChangeTime: state.dtsChangeTime,
|
||||
latestChangedDtsFile: state.latestChangedDtsFile,
|
||||
hasChangedEmitSignature: state.hasChangedEmitSignature,
|
||||
changedFilesSet: outFilePath ? new Set(state.changedFilesSet) : undefined,
|
||||
};
|
||||
@@ -315,7 +315,7 @@ namespace ts {
|
||||
state.programEmitComplete = savedEmitState.programEmitComplete;
|
||||
state.emitSignatures = savedEmitState.emitSignatures;
|
||||
state.outSignature = savedEmitState.outSignature;
|
||||
state.dtsChangeTime = savedEmitState.dtsChangeTime;
|
||||
state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile;
|
||||
state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature;
|
||||
if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet;
|
||||
}
|
||||
@@ -333,7 +333,13 @@ namespace ts {
|
||||
* This is to allow the callers to be able to actually remove affected file only when the operation is complete
|
||||
* eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
|
||||
*/
|
||||
function getNextAffectedFile(state: BuilderProgramState, cancellationToken: CancellationToken | undefined, computeHash: BuilderState.ComputeHash, host: BuilderProgramHost): SourceFile | Program | undefined {
|
||||
function getNextAffectedFile(
|
||||
state: BuilderProgramState,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: BuilderState.ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
host: BuilderProgramHost
|
||||
): SourceFile | Program | undefined {
|
||||
while (true) {
|
||||
const { affectedFiles } = state;
|
||||
if (affectedFiles) {
|
||||
@@ -344,7 +350,14 @@ namespace ts {
|
||||
if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
|
||||
// Set the next affected file as seen and remove the cached semantic diagnostics
|
||||
state.affectedFilesIndex = affectedFilesIndex;
|
||||
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
|
||||
handleDtsMayChangeOfAffectedFile(
|
||||
state,
|
||||
affectedFile,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
host
|
||||
);
|
||||
return affectedFile;
|
||||
}
|
||||
affectedFilesIndex++;
|
||||
@@ -376,7 +389,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Get next batch of affected files
|
||||
state.affectedFiles = BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
|
||||
state.affectedFiles = BuilderState.getFilesAffectedByWithOldState(
|
||||
state,
|
||||
program,
|
||||
nextKey.value,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
);
|
||||
state.currentChangedFilePath = nextKey.value;
|
||||
state.affectedFilesIndex = 0;
|
||||
if (!state.seenAffectedFiles) state.seenAffectedFiles = new Set();
|
||||
@@ -435,6 +455,7 @@ namespace ts {
|
||||
affectedFile: SourceFile,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: BuilderState.ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
host: BuilderProgramHost,
|
||||
) {
|
||||
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
|
||||
@@ -451,11 +472,19 @@ namespace ts {
|
||||
affectedFile,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) return;
|
||||
handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
|
||||
handleDtsMayChangeOfReferencingExportOfAffectedFile(
|
||||
state,
|
||||
affectedFile,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
host,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -467,6 +496,7 @@ namespace ts {
|
||||
path: Path,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: BuilderState.ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
host: BuilderProgramHost
|
||||
): void {
|
||||
removeSemanticDiagnosticsOf(state, path);
|
||||
@@ -486,6 +516,7 @@ namespace ts {
|
||||
sourceFile,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
!host.disableUseFileVersionAsSignature
|
||||
);
|
||||
// If not dts emit, nothing more to do
|
||||
@@ -520,6 +551,7 @@ namespace ts {
|
||||
filePath: Path,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: BuilderState.ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
host: BuilderProgramHost,
|
||||
): boolean {
|
||||
if (!state.fileInfos.get(filePath)?.affectsGlobalScope) return false;
|
||||
@@ -530,6 +562,7 @@ namespace ts {
|
||||
file.resolvedPath,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
host,
|
||||
));
|
||||
removeDiagnosticsOfLibraryFiles(state);
|
||||
@@ -544,6 +577,7 @@ namespace ts {
|
||||
affectedFile: SourceFile,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: BuilderState.ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
host: BuilderProgramHost
|
||||
) {
|
||||
// If there was change in signature (dts output) for the changed file,
|
||||
@@ -561,8 +595,8 @@ namespace ts {
|
||||
const currentPath = queue.pop()!;
|
||||
if (!seenFileNamesMap.has(currentPath)) {
|
||||
seenFileNamesMap.set(currentPath, true);
|
||||
if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) return;
|
||||
handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
|
||||
if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host)) return;
|
||||
handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
|
||||
if (isChangedSignature(state, currentPath)) {
|
||||
const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath)!;
|
||||
queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
|
||||
@@ -575,7 +609,7 @@ namespace ts {
|
||||
// Go through exported modules from cache first
|
||||
// If exported modules has path, all files referencing file exported from are affected
|
||||
state.exportedModulesMap.getKeys(affectedFile.resolvedPath)?.forEach(exportedFromPath => {
|
||||
if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) return true;
|
||||
if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host)) return true;
|
||||
const references = state.referencedMap!.getKeys(exportedFromPath);
|
||||
return references && forEachKey(references, filePath =>
|
||||
handleDtsMayChangeOfFileAndExportsOfFile(
|
||||
@@ -584,6 +618,7 @@ namespace ts {
|
||||
seenFileAndExportsOfFile,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
host,
|
||||
)
|
||||
);
|
||||
@@ -600,12 +635,13 @@ namespace ts {
|
||||
seenFileAndExportsOfFile: Set<string>,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: BuilderState.ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
host: BuilderProgramHost,
|
||||
): boolean | undefined {
|
||||
if (!tryAddToSet(seenFileAndExportsOfFile, filePath)) return undefined;
|
||||
|
||||
if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) return true;
|
||||
handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
|
||||
if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host)) return true;
|
||||
handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
|
||||
|
||||
// If exported modules has path, all files referencing file exported from are affected
|
||||
state.exportedModulesMap!.getKeys(filePath)?.forEach(exportedFromPath =>
|
||||
@@ -615,6 +651,7 @@ namespace ts {
|
||||
seenFileAndExportsOfFile,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
host,
|
||||
)
|
||||
);
|
||||
@@ -627,6 +664,7 @@ namespace ts {
|
||||
referencingFilePath,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
host,
|
||||
)
|
||||
);
|
||||
@@ -757,7 +795,8 @@ namespace ts {
|
||||
affectedFilesPendingEmit?: ProgramBuilderInfoFilePendingEmit[];
|
||||
changeFileSet?: readonly ProgramBuildInfoFileId[];
|
||||
emitSignatures?: readonly ProgramBuildInfoEmitSignature[];
|
||||
dtsChangeTime?: number;
|
||||
// Because this is only output file in the program, we dont need fileId to deduplicate name
|
||||
latestChangedDtsFile?: string;
|
||||
}
|
||||
|
||||
export interface ProgramBundleEmitBuildInfo {
|
||||
@@ -765,7 +804,7 @@ namespace ts {
|
||||
fileInfos: readonly string[];
|
||||
options: CompilerOptions | undefined;
|
||||
outSignature?: string;
|
||||
dtsChangeTime?: number;
|
||||
latestChangedDtsFile?: string;
|
||||
}
|
||||
|
||||
export type ProgramBuildInfo = ProgramMultiFileEmitBuildInfo | ProgramBundleEmitBuildInfo;
|
||||
@@ -777,13 +816,13 @@ namespace ts {
|
||||
/**
|
||||
* Gets the program information to be emitted in buildInfo so that we can use it to create new program
|
||||
*/
|
||||
function getProgramBuildInfo(state: BuilderProgramState, getCanonicalFileName: GetCanonicalFileName, host: BuilderProgramHost): ProgramBuildInfo | undefined {
|
||||
function getProgramBuildInfo(state: BuilderProgramState, getCanonicalFileName: GetCanonicalFileName): ProgramBuildInfo | undefined {
|
||||
const outFilePath = outFile(state.compilerOptions);
|
||||
if (outFilePath && !state.compilerOptions.composite) return;
|
||||
const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
|
||||
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions)!, currentDirectory));
|
||||
// Update the dtsChange time in buildInfo
|
||||
state.dtsChangeTime = state.hasChangedEmitSignature ? getCurrentTime(host).getTime() : state.dtsChangeTime;
|
||||
// Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path
|
||||
const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
|
||||
if (outFilePath) {
|
||||
const fileNames: string[] = [];
|
||||
const fileInfos: string[] = [];
|
||||
@@ -798,7 +837,7 @@ namespace ts {
|
||||
fileInfos,
|
||||
options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
|
||||
outSignature: state.outSignature,
|
||||
dtsChangeTime: state.dtsChangeTime,
|
||||
latestChangedDtsFile,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
@@ -901,7 +940,7 @@ namespace ts {
|
||||
affectedFilesPendingEmit,
|
||||
changeFileSet,
|
||||
emitSignatures,
|
||||
dtsChangeTime: state.dtsChangeTime,
|
||||
latestChangedDtsFile,
|
||||
};
|
||||
return result;
|
||||
|
||||
@@ -1038,8 +1077,45 @@ namespace ts {
|
||||
return { host, newProgram, oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || emptyArray };
|
||||
}
|
||||
|
||||
export function computeSignature(text: string, data: WriteFileCallbackData | undefined, computeHash: BuilderState.ComputeHash | undefined) {
|
||||
return BuilderState.computeSignature(data?.sourceMapUrlPos !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
|
||||
function getTextHandlingSourceMapForSignature(text: string, data: WriteFileCallbackData | undefined) {
|
||||
return data?.sourceMapUrlPos !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
|
||||
}
|
||||
|
||||
export function computeSignatureWithDiagnostics(
|
||||
sourceFile: SourceFile,
|
||||
text: string,
|
||||
computeHash: BuilderState.ComputeHash | undefined,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
data: WriteFileCallbackData | undefined
|
||||
) {
|
||||
text = getTextHandlingSourceMapForSignature(text, data);
|
||||
let sourceFileDirectory: string | undefined;
|
||||
if (data?.diagnostics?.length) {
|
||||
text += data.diagnostics.map(diagnostic =>
|
||||
`${locationInfo(diagnostic)}${DiagnosticCategory[diagnostic.category]}${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText)}`
|
||||
).join("\n");
|
||||
}
|
||||
return (computeHash ?? generateDjb2Hash)(text);
|
||||
|
||||
function flattenDiagnosticMessageText(diagnostic: string | DiagnosticMessageChain | undefined): string {
|
||||
return isString(diagnostic) ?
|
||||
diagnostic :
|
||||
diagnostic === undefined ?
|
||||
"" :
|
||||
!diagnostic.next ?
|
||||
diagnostic.messageText :
|
||||
diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n");
|
||||
}
|
||||
|
||||
function locationInfo(diagnostic: DiagnosticWithLocation) {
|
||||
if (diagnostic.file.resolvedPath === sourceFile.resolvedPath) return `(${diagnostic.start},${diagnostic.length})`;
|
||||
if (sourceFileDirectory === undefined) sourceFileDirectory = getDirectoryPath(sourceFile.resolvedPath);
|
||||
return `${ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName))}(${diagnostic.start},${diagnostic.length})`;
|
||||
}
|
||||
}
|
||||
|
||||
export function computeSignature(text: string, computeHash: BuilderState.ComputeHash | undefined, data?: WriteFileCallbackData) {
|
||||
return (computeHash ?? generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
|
||||
}
|
||||
|
||||
export function createBuilderProgram(kind: BuilderProgramKind.SemanticDiagnosticsBuilderProgram, builderCreationParameters: BuilderCreationParameters): SemanticDiagnosticsBuilderProgram;
|
||||
@@ -1062,7 +1138,7 @@ namespace ts {
|
||||
*/
|
||||
const computeHash = maybeBind(host, host.createHash);
|
||||
const state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
|
||||
newProgram.getProgramBuildInfo = () => getProgramBuildInfo(state, getCanonicalFileName, host);
|
||||
newProgram.getProgramBuildInfo = () => getProgramBuildInfo(state, getCanonicalFileName);
|
||||
|
||||
// To ensure that we arent storing any references to old program or new program without state
|
||||
newProgram = undefined!; // TODO: GH#18217
|
||||
@@ -1074,6 +1150,7 @@ namespace ts {
|
||||
builderProgram.getState = getState;
|
||||
builderProgram.saveEmitState = () => backupBuilderProgramEmitState(state);
|
||||
builderProgram.restoreEmitState = (saved) => restoreBuilderProgramEmitState(state, saved);
|
||||
builderProgram.hasChangedEmitSignature = () => !!state.hasChangedEmitSignature;
|
||||
builderProgram.getAllDependencies = sourceFile => BuilderState.getAllDependencies(state, Debug.checkDefined(state.program), sourceFile);
|
||||
builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
|
||||
builderProgram.emit = emit;
|
||||
@@ -1108,7 +1185,7 @@ namespace ts {
|
||||
* in that order would be used to write the files
|
||||
*/
|
||||
function emitNextAffectedFile(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): AffectedFileResult<EmitResult> {
|
||||
let affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
||||
let affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
|
||||
let emitKind = BuilderFileEmit.Full;
|
||||
let isPendingEmitFile = false;
|
||||
if (!affected) {
|
||||
@@ -1165,24 +1242,32 @@ namespace ts {
|
||||
if (isDeclarationFileName(fileName)) {
|
||||
if (!outFile(state.compilerOptions)) {
|
||||
Debug.assert(sourceFiles?.length === 1);
|
||||
let newSignature;
|
||||
let emitSignature;
|
||||
if (!customTransformers) {
|
||||
const file = sourceFiles[0];
|
||||
const info = state.fileInfos.get(file.resolvedPath)!;
|
||||
if (info.signature === file.version) {
|
||||
newSignature = computeSignature(text, data, computeHash);
|
||||
if (newSignature !== file.version) { // Update it
|
||||
if (host.storeFilesChangingSignatureDuringEmit) (state.filesChangingSignature ||= new Set()).add(file.resolvedPath);
|
||||
const signature = computeSignatureWithDiagnostics(
|
||||
file,
|
||||
text,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
data,
|
||||
);
|
||||
// With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts
|
||||
if (!data?.diagnostics?.length) emitSignature = signature;
|
||||
if (signature !== file.version) { // Update it
|
||||
if (host.storeFilesChangingSignatureDuringEmit) (state.filesChangingSignature ??= new Set()).add(file.resolvedPath);
|
||||
if (state.exportedModulesMap) BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
|
||||
if (state.affectedFiles) {
|
||||
// Keep old signature so we know what to undo if cancellation happens
|
||||
const existing = state.oldSignatures?.get(file.resolvedPath);
|
||||
if (existing === undefined) (state.oldSignatures ||= new Map()).set(file.resolvedPath, info.signature || false);
|
||||
info.signature = newSignature;
|
||||
if (existing === undefined) (state.oldSignatures ??= new Map()).set(file.resolvedPath, info.signature || false);
|
||||
info.signature = signature;
|
||||
}
|
||||
else {
|
||||
// These are directly commited
|
||||
info.signature = newSignature;
|
||||
info.signature = signature;
|
||||
state.oldExportedModulesMap?.clear();
|
||||
}
|
||||
}
|
||||
@@ -1195,19 +1280,21 @@ namespace ts {
|
||||
if (state.compilerOptions.composite) {
|
||||
const filePath = sourceFiles[0].resolvedPath;
|
||||
const oldSignature = state.emitSignatures?.get(filePath);
|
||||
newSignature ||= computeSignature(text, data, computeHash);
|
||||
if (newSignature !== oldSignature) {
|
||||
(state.emitSignatures ||= new Map()).set(filePath, newSignature);
|
||||
state.hasChangedEmitSignature = true;
|
||||
}
|
||||
emitSignature ??= computeSignature(text, computeHash, data);
|
||||
// Dont write dts files if they didn't change
|
||||
if (emitSignature === oldSignature) return;
|
||||
(state.emitSignatures ??= new Map()).set(filePath, emitSignature);
|
||||
state.hasChangedEmitSignature = true;
|
||||
state.latestChangedDtsFile = fileName;
|
||||
}
|
||||
}
|
||||
else if (state.compilerOptions.composite) {
|
||||
const newSignature = computeSignature(text, data, computeHash);
|
||||
if (newSignature !== state.outSignature) {
|
||||
state.outSignature = newSignature;
|
||||
state.hasChangedEmitSignature = true;
|
||||
}
|
||||
const newSignature = computeSignature(text, computeHash, data);
|
||||
// Dont write dts files if they didn't change
|
||||
if (newSignature === state.outSignature) return;
|
||||
state.outSignature = newSignature;
|
||||
state.hasChangedEmitSignature = true;
|
||||
state.latestChangedDtsFile = fileName;
|
||||
}
|
||||
}
|
||||
if (writeFile) writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
||||
@@ -1287,7 +1374,7 @@ namespace ts {
|
||||
*/
|
||||
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<readonly Diagnostic[]> {
|
||||
while (true) {
|
||||
const affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
||||
const affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
|
||||
if (!affected) {
|
||||
// Done
|
||||
return undefined;
|
||||
@@ -1389,11 +1476,12 @@ namespace ts {
|
||||
let state: ReusableBuilderProgramState;
|
||||
let filePaths: Path[] | undefined;
|
||||
let filePathsSetList: Set<Path>[] | undefined;
|
||||
const latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
|
||||
if (isProgramBundleEmitBuildInfo(program)) {
|
||||
state = {
|
||||
fileInfos: new Map(),
|
||||
compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
|
||||
dtsChangeTime: program.dtsChangeTime,
|
||||
latestChangedDtsFile,
|
||||
outSignature: program.outSignature,
|
||||
};
|
||||
}
|
||||
@@ -1423,7 +1511,7 @@ namespace ts {
|
||||
affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && arrayToMap(program.affectedFilesPendingEmit, value => toFilePath(value[0]), value => value[1]),
|
||||
affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
|
||||
changedFilesSet: new Set(map(program.changeFileSet, toFilePath)),
|
||||
dtsChangeTime: program.dtsChangeTime,
|
||||
latestChangedDtsFile,
|
||||
emitSignatures: emitSignatures?.size ? emitSignatures : undefined,
|
||||
};
|
||||
}
|
||||
@@ -1451,6 +1539,7 @@ namespace ts {
|
||||
getSemanticDiagnosticsOfNextAffectedFile: notImplemented,
|
||||
emitBuildInfo: notImplemented,
|
||||
close: noop,
|
||||
hasChangedEmitSignature: returnFalse,
|
||||
};
|
||||
|
||||
function toPath(path: string) {
|
||||
|
||||
@@ -42,6 +42,8 @@ namespace ts {
|
||||
saveEmitState(): SavedBuildProgramEmitState;
|
||||
/*@internal*/
|
||||
restoreEmitState(saved: SavedBuildProgramEmitState): void;
|
||||
/*@internal*/
|
||||
hasChangedEmitSignature?(): boolean;
|
||||
/**
|
||||
* Returns current program
|
||||
*/
|
||||
|
||||
@@ -3,8 +3,8 @@ namespace ts {
|
||||
export function getFileEmitOutput(program: Program, sourceFile: SourceFile, emitOnlyDtsFiles: boolean,
|
||||
cancellationToken?: CancellationToken, customTransformers?: CustomTransformers, forceDtsEmit?: boolean): EmitOutput {
|
||||
const outputFiles: OutputFile[] = [];
|
||||
const { emitSkipped, diagnostics, exportedModulesFromDeclarationEmit } = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit);
|
||||
return { outputFiles, emitSkipped, diagnostics, exportedModulesFromDeclarationEmit };
|
||||
const { emitSkipped, diagnostics } = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit);
|
||||
return { outputFiles, emitSkipped, diagnostics };
|
||||
|
||||
function writeFile(fileName: string, text: string, writeByteOrderMark: boolean) {
|
||||
outputFiles.push({ name: fileName, writeByteOrderMark, text });
|
||||
@@ -321,24 +321,45 @@ namespace ts {
|
||||
/**
|
||||
* Gets the files affected by the path from the program
|
||||
*/
|
||||
export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash): readonly SourceFile[] {
|
||||
const result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
|
||||
export function getFilesAffectedBy(
|
||||
state: BuilderState,
|
||||
programOfThisState: Program,
|
||||
path: Path,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
): readonly SourceFile[] {
|
||||
const result = getFilesAffectedByWithOldState(
|
||||
state,
|
||||
programOfThisState,
|
||||
path,
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
);
|
||||
state.oldSignatures?.clear();
|
||||
state.oldExportedModulesMap?.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getFilesAffectedByWithOldState(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash): readonly SourceFile[] {
|
||||
export function getFilesAffectedByWithOldState(
|
||||
state: BuilderState,
|
||||
programOfThisState: Program,
|
||||
path: Path,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
): readonly SourceFile[] {
|
||||
const sourceFile = programOfThisState.getSourceFileByPath(path);
|
||||
if (!sourceFile) {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
|
||||
if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
|
||||
return [sourceFile];
|
||||
}
|
||||
|
||||
return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
|
||||
return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
|
||||
}
|
||||
|
||||
export function updateSignatureOfFile(state: BuilderState, signature: string | undefined, path: Path) {
|
||||
@@ -349,7 +370,15 @@ namespace ts {
|
||||
/**
|
||||
* Returns if the shape of the signature has changed since last emit
|
||||
*/
|
||||
export function updateShapeSignature(state: BuilderState, programOfThisState: Program, sourceFile: SourceFile, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, useFileVersionAsSignature = state.useFileVersionAsSignature) {
|
||||
export function updateShapeSignature(
|
||||
state: BuilderState,
|
||||
programOfThisState: Program,
|
||||
sourceFile: SourceFile,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
useFileVersionAsSignature = state.useFileVersionAsSignature
|
||||
) {
|
||||
// If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
|
||||
if (state.hasCalledUpdateShapeSignature?.has(sourceFile.resolvedPath)) return false;
|
||||
|
||||
@@ -357,22 +386,26 @@ namespace ts {
|
||||
const prevSignature = info.signature;
|
||||
let latestSignature: string | undefined;
|
||||
if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
|
||||
const emitOutput = getFileEmitOutput(
|
||||
programOfThisState,
|
||||
programOfThisState.emit(
|
||||
sourceFile,
|
||||
/*emitOnlyDtsFiles*/ true,
|
||||
(fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) => {
|
||||
Debug.assert(isDeclarationFileName(fileName), `File extension for signature expected to be dts: Got:: ${fileName}`);
|
||||
latestSignature = computeSignatureWithDiagnostics(
|
||||
sourceFile,
|
||||
text,
|
||||
computeHash,
|
||||
getCanonicalFileName,
|
||||
data,
|
||||
);
|
||||
if (latestSignature !== prevSignature) {
|
||||
updateExportedModules(state, sourceFile, sourceFiles![0].exportedModulesFromDeclarationEmit);
|
||||
}
|
||||
},
|
||||
cancellationToken,
|
||||
/*emitOnlyDtsFiles*/ true,
|
||||
/*customTransformers*/ undefined,
|
||||
/*forceDtsEmit*/ true
|
||||
);
|
||||
const firstDts = firstOrUndefined(emitOutput.outputFiles);
|
||||
if (firstDts) {
|
||||
Debug.assert(isDeclarationFileName(firstDts.name), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`);
|
||||
latestSignature = computeSignature(firstDts.text, computeHash);
|
||||
if (latestSignature !== prevSignature) {
|
||||
updateExportedModules(state, sourceFile, emitOutput.exportedModulesFromDeclarationEmit);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Default is to use file version as signature
|
||||
if (latestSignature === undefined) {
|
||||
@@ -395,10 +428,6 @@ namespace ts {
|
||||
return latestSignature !== prevSignature;
|
||||
}
|
||||
|
||||
export function computeSignature(text: string, computeHash: ComputeHash | undefined) {
|
||||
return (computeHash || generateDjb2Hash)(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Coverts the declaration emit result into exported modules map
|
||||
*/
|
||||
@@ -556,7 +585,14 @@ namespace ts {
|
||||
/**
|
||||
* When program emits modular code, gets the files affected by the sourceFile whose shape has changed
|
||||
*/
|
||||
function getFilesAffectedByUpdatedShapeWhenModuleEmit(state: BuilderState, programOfThisState: Program, sourceFileWithUpdatedShape: SourceFile, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash) {
|
||||
function getFilesAffectedByUpdatedShapeWhenModuleEmit(
|
||||
state: BuilderState,
|
||||
programOfThisState: Program,
|
||||
sourceFileWithUpdatedShape: SourceFile,
|
||||
cancellationToken: CancellationToken | undefined,
|
||||
computeHash: ComputeHash,
|
||||
getCanonicalFileName: GetCanonicalFileName,
|
||||
) {
|
||||
if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
|
||||
return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
|
||||
}
|
||||
@@ -579,7 +615,7 @@ namespace ts {
|
||||
if (!seenFileNamesMap.has(currentPath)) {
|
||||
const currentSourceFile = programOfThisState.getSourceFileByPath(currentPath)!;
|
||||
seenFileNamesMap.set(currentPath, currentSourceFile);
|
||||
if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
|
||||
if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
|
||||
queue.push(...getReferencedByPaths(state, currentSourceFile.resolvedPath));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ namespace ts {
|
||||
outputFiles: OutputFile[];
|
||||
emitSkipped: boolean;
|
||||
/* @internal */ diagnostics: readonly Diagnostic[];
|
||||
/* @internal */ exportedModulesFromDeclarationEmit?: ExportedModulesFromDeclarationEmit;
|
||||
}
|
||||
|
||||
export interface OutputFile {
|
||||
|
||||
+769
-442
File diff suppressed because it is too large
Load Diff
+47
-1
@@ -1492,6 +1492,47 @@ namespace ts {
|
||||
return createMultiMap() as UnderscoreEscapedMultiMap<T>;
|
||||
}
|
||||
|
||||
export function createQueue<T>(items?: readonly T[]): Queue<T> {
|
||||
const elements: (T | undefined)[] = items?.slice() || [];
|
||||
let headIndex = 0;
|
||||
|
||||
function isEmpty() {
|
||||
return headIndex === elements.length;
|
||||
}
|
||||
|
||||
function enqueue(...items: T[]) {
|
||||
elements.push(...items);
|
||||
}
|
||||
|
||||
function dequeue(): T {
|
||||
if (isEmpty()) {
|
||||
throw new Error("Queue is empty");
|
||||
}
|
||||
|
||||
const result = elements[headIndex] as T;
|
||||
elements[headIndex] = undefined; // Don't keep referencing dequeued item
|
||||
headIndex++;
|
||||
|
||||
// If more than half of the queue is empty, copy the remaining elements to the
|
||||
// front and shrink the array (unless we'd be saving fewer than 100 slots)
|
||||
if (headIndex > 100 && headIndex > (elements.length >> 1)) {
|
||||
const newLength = elements.length - headIndex;
|
||||
elements.copyWithin(/*target*/ 0, /*start*/ headIndex);
|
||||
|
||||
elements.length = newLength;
|
||||
headIndex = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return {
|
||||
enqueue,
|
||||
dequeue,
|
||||
isEmpty,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Set with custom equality and hash code functionality. This is useful when you
|
||||
* want to use something looser than object identity - e.g. "has the same span".
|
||||
@@ -1683,6 +1724,11 @@ namespace ts {
|
||||
/** Does nothing. */
|
||||
export function noop(_?: unknown): void { }
|
||||
|
||||
export const noopPush: Push<any> = {
|
||||
push: noop,
|
||||
length: 0
|
||||
};
|
||||
|
||||
/** Do nothing and return false */
|
||||
export function returnFalse(): false {
|
||||
return false;
|
||||
@@ -2064,7 +2110,7 @@ namespace ts {
|
||||
* and 1 insertion/deletion at 3 characters)
|
||||
*/
|
||||
export function getSpellingSuggestion<T>(name: string, candidates: T[], getName: (candidate: T) => string | undefined): T | undefined {
|
||||
const maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
|
||||
const maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
|
||||
let bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
|
||||
let bestCandidate: T | undefined;
|
||||
for (const candidate of candidates) {
|
||||
|
||||
@@ -394,6 +394,22 @@ namespace ts {
|
||||
return formatEnum(flags, (ts as any).FlowFlags, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function formatRelationComparisonResult(result: RelationComparisonResult | undefined): string {
|
||||
return formatEnum(result, (ts as any).RelationComparisonResult, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function formatCheckMode(mode: CheckMode | undefined): string {
|
||||
return formatEnum(mode, (ts as any).CheckMode, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function formatSignatureCheckMode(mode: SignatureCheckMode | undefined): string {
|
||||
return formatEnum(mode, (ts as any).SignatureCheckMode, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function formatTypeFacts(facts: TypeFacts | undefined): string {
|
||||
return formatEnum(facts, (ts as any).TypeFacts, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
let isDebugInfoEnabled = false;
|
||||
|
||||
interface ExtendedDebugModule {
|
||||
@@ -748,5 +764,53 @@ namespace ts {
|
||||
const deprecation = createDeprecation(options?.name ?? getFunctionName(func), options);
|
||||
return wrapFunction(deprecation, func);
|
||||
}
|
||||
|
||||
export function formatVariance(varianceFlags: VarianceFlags) {
|
||||
const variance = varianceFlags & VarianceFlags.VarianceMask;
|
||||
let result =
|
||||
variance === VarianceFlags.Invariant ? "in out" :
|
||||
variance === VarianceFlags.Bivariant ? "[bivariant]" :
|
||||
variance === VarianceFlags.Contravariant ? "in" :
|
||||
variance === VarianceFlags.Covariant ? "out" :
|
||||
variance === VarianceFlags.Independent ? "[independent]" : "";
|
||||
if (varianceFlags & VarianceFlags.Unmeasurable) {
|
||||
result += " (unmeasurable)";
|
||||
}
|
||||
else if (varianceFlags & VarianceFlags.Unreliable) {
|
||||
result += " (unreliable)";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export type DebugType = Type & { __debugTypeToString(): string }; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
export class DebugTypeMapper {
|
||||
declare kind: TypeMapKind;
|
||||
__debugToString(): string { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
type<TypeMapper>(this);
|
||||
switch (this.kind) {
|
||||
case TypeMapKind.Function: return this.debugInfo?.() || "(function mapper)";
|
||||
case TypeMapKind.Simple: return `${(this.source as DebugType).__debugTypeToString()} -> ${(this.target as DebugType).__debugTypeToString()}`;
|
||||
case TypeMapKind.Array: return zipWith<DebugType, DebugType | string, unknown>(
|
||||
this.sources as readonly DebugType[],
|
||||
this.targets as readonly DebugType[] || map(this.sources, () => "any"),
|
||||
(s, t) => `${s.__debugTypeToString()} -> ${typeof t === "string" ? t : t.__debugTypeToString()}`).join(", ");
|
||||
case TypeMapKind.Deferred: return zipWith(
|
||||
this.sources,
|
||||
this.targets,
|
||||
(s, t) => `${(s as DebugType).__debugTypeToString()} -> ${(t() as DebugType).__debugTypeToString()}`).join(", ");
|
||||
case TypeMapKind.Merged:
|
||||
case TypeMapKind.Composite: return `m1: ${(this.mapper1 as unknown as DebugTypeMapper).__debugToString().split("\n").join("\n ")}
|
||||
m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n").join("\n ")}`;
|
||||
default: return assertNever(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function attachDebugPrototypeIfDebug(mapper: TypeMapper): TypeMapper {
|
||||
if (isDebugging) {
|
||||
return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype);
|
||||
}
|
||||
return mapper;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1464,12 +1464,28 @@
|
||||
"category": "Message",
|
||||
"code": 1457
|
||||
},
|
||||
"File is ECMAScript module because '{0}' has field \"type\" with value \"module\"": {
|
||||
"category": "Message",
|
||||
"code": 1458
|
||||
},
|
||||
"File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\"": {
|
||||
"category": "Message",
|
||||
"code": 1459
|
||||
},
|
||||
"File is CommonJS module because '{0}' does not have field \"type\"": {
|
||||
"category": "Message",
|
||||
"code": 1460
|
||||
},
|
||||
"File is CommonJS module because 'package.json' was not found": {
|
||||
"category": "Message",
|
||||
"code": 1461
|
||||
},
|
||||
|
||||
"The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.": {
|
||||
"category": "Error",
|
||||
"code": 1470
|
||||
},
|
||||
"Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.": {
|
||||
"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.": {
|
||||
"category": "Error",
|
||||
"code": 1471
|
||||
},
|
||||
@@ -1493,6 +1509,34 @@
|
||||
"category": "Message",
|
||||
"code": 1476
|
||||
},
|
||||
"An instantiation expression cannot be followed by a property access.": {
|
||||
"category": "Error",
|
||||
"code": 1477
|
||||
},
|
||||
"Identifier or string literal expected.": {
|
||||
"category": "Error",
|
||||
"code": 1478
|
||||
},
|
||||
"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.": {
|
||||
"category": "Error",
|
||||
"code": 1479
|
||||
},
|
||||
"To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`.": {
|
||||
"category": "Message",
|
||||
"code": 1480
|
||||
},
|
||||
"To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'.": {
|
||||
"category": "Message",
|
||||
"code": 1481
|
||||
},
|
||||
"To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 1482
|
||||
},
|
||||
"To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`.": {
|
||||
"category": "Message",
|
||||
"code": 1483
|
||||
},
|
||||
|
||||
"The types of '{0}' are incompatible between these types.": {
|
||||
"category": "Error",
|
||||
@@ -2352,6 +2396,10 @@
|
||||
"category": "Error",
|
||||
"code": 2513
|
||||
},
|
||||
"A tuple type cannot be indexed with a negative value.": {
|
||||
"category": "Error",
|
||||
"code": 2514
|
||||
},
|
||||
"Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 2515
|
||||
@@ -3503,6 +3551,10 @@
|
||||
"category": "Error",
|
||||
"code": 2843
|
||||
},
|
||||
"Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.": {
|
||||
"category": "Error",
|
||||
"code": 2844
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
+15
-22
@@ -288,7 +288,6 @@ namespace ts {
|
||||
const { enter, exit } = performance.createTimer("printTime", "beforePrint", "afterPrint");
|
||||
let bundleBuildInfo: BundleBuildInfo | undefined;
|
||||
let emitSkipped = false;
|
||||
let exportedModulesFromDeclarationEmit: ExportedModulesFromDeclarationEmit | undefined;
|
||||
|
||||
// Emit each output file
|
||||
enter();
|
||||
@@ -308,7 +307,6 @@ namespace ts {
|
||||
diagnostics: emitterDiagnostics.getDiagnostics(),
|
||||
emittedFiles: emittedFilesList,
|
||||
sourceMaps: sourceMapDataList,
|
||||
exportedModulesFromDeclarationEmit
|
||||
};
|
||||
|
||||
function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath }: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle | undefined) {
|
||||
@@ -381,7 +379,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Make sure not to write js file and source map file if any of them cannot be written
|
||||
if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
|
||||
if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
|
||||
emitSkipped = true;
|
||||
return;
|
||||
}
|
||||
@@ -414,7 +412,7 @@ namespace ts {
|
||||
});
|
||||
|
||||
Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
|
||||
printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
|
||||
printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions);
|
||||
|
||||
// Clean up emit nodes on parse tree
|
||||
transform.dispose();
|
||||
@@ -453,7 +451,7 @@ namespace ts {
|
||||
noEmitHelpers: true,
|
||||
module: compilerOptions.module,
|
||||
target: compilerOptions.target,
|
||||
sourceMap: compilerOptions.sourceMap,
|
||||
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
|
||||
inlineSourceMap: compilerOptions.inlineSourceMap,
|
||||
extendedDiagnostics: compilerOptions.extendedDiagnostics,
|
||||
onlyPrintJsDocStyle: true,
|
||||
@@ -478,20 +476,16 @@ namespace ts {
|
||||
printSourceFileOrBundle(
|
||||
declarationFilePath,
|
||||
declarationMapPath,
|
||||
declarationTransform.transformed[0],
|
||||
declarationTransform,
|
||||
declarationPrinter,
|
||||
{
|
||||
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
|
||||
sourceMap: printerOptions.sourceMap,
|
||||
sourceRoot: compilerOptions.sourceRoot,
|
||||
mapRoot: compilerOptions.mapRoot,
|
||||
extendedDiagnostics: compilerOptions.extendedDiagnostics,
|
||||
// Explicitly do not passthru either `inline` option
|
||||
}
|
||||
);
|
||||
if (forceDtsEmit && declarationTransform.transformed[0].kind === SyntaxKind.SourceFile) {
|
||||
const sourceFile = declarationTransform.transformed[0];
|
||||
exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
|
||||
}
|
||||
}
|
||||
declarationTransform.dispose();
|
||||
if (bundleBuildInfo) bundleBuildInfo.dts = declarationPrinter.bundleFileInfo;
|
||||
@@ -511,7 +505,8 @@ namespace ts {
|
||||
forEachChild(node, collectLinkedAliases);
|
||||
}
|
||||
|
||||
function printSourceFileOrBundle(jsFilePath: string, sourceMapFilePath: string | undefined, sourceFileOrBundle: SourceFile | Bundle, printer: Printer, mapOptions: SourceMapOptions) {
|
||||
function printSourceFileOrBundle(jsFilePath: string, sourceMapFilePath: string | undefined, transform: TransformationResult<SourceFile | Bundle>, printer: Printer, mapOptions: SourceMapOptions) {
|
||||
const sourceFileOrBundle = transform.transformed[0];
|
||||
const bundle = sourceFileOrBundle.kind === SyntaxKind.Bundle ? sourceFileOrBundle : undefined;
|
||||
const sourceFile = sourceFileOrBundle.kind === SyntaxKind.SourceFile ? sourceFileOrBundle : undefined;
|
||||
const sourceFiles = bundle ? bundle.sourceFiles : [sourceFile!];
|
||||
@@ -559,7 +554,7 @@ namespace ts {
|
||||
if (sourceMapFilePath) {
|
||||
const sourceMap = sourceMapGenerator.toString();
|
||||
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
|
||||
if (printer.bundleFileInfo) printer.bundleFileInfo.mapHash = BuilderState.computeSignature(sourceMap, maybeBind(host, host.createHash));
|
||||
if (printer.bundleFileInfo) printer.bundleFileInfo.mapHash = computeSignature(sourceMap, maybeBind(host, host.createHash));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -568,10 +563,10 @@ namespace ts {
|
||||
|
||||
// Write the output file
|
||||
const text = writer.getText();
|
||||
writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos });
|
||||
writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos, diagnostics: transform.diagnostics });
|
||||
// We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo
|
||||
// This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode
|
||||
if (printer.bundleFileInfo) printer.bundleFileInfo.hash = BuilderState.computeSignature(text, maybeBind(host, host.createHash));
|
||||
if (printer.bundleFileInfo) printer.bundleFileInfo.hash = computeSignature(text, maybeBind(host, host.createHash));
|
||||
|
||||
// Reset state
|
||||
writer.clear();
|
||||
@@ -717,7 +712,6 @@ namespace ts {
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getNewLine(): string;
|
||||
createHash?(data: string): string;
|
||||
now?(): Date;
|
||||
getBuildInfo?(fileName: string, configFilePath: string | undefined): BuildInfo | undefined;
|
||||
}
|
||||
|
||||
@@ -774,20 +768,20 @@ namespace ts {
|
||||
const jsFileText = host.readFile(Debug.checkDefined(jsFilePath));
|
||||
if (!jsFileText) return jsFilePath!;
|
||||
// If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
|
||||
if (BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) return jsFilePath!;
|
||||
if (computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) return jsFilePath!;
|
||||
const sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
|
||||
// error if no source map or for now if inline sourcemap
|
||||
if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) return sourceMapFilePath || "inline sourcemap decoding";
|
||||
if (sourceMapFilePath && BuilderState.computeSignature(sourceMapText!, createHash) !== buildInfo.bundle.js.mapHash) return sourceMapFilePath;
|
||||
if (sourceMapFilePath && computeSignature(sourceMapText!, createHash) !== buildInfo.bundle.js.mapHash) return sourceMapFilePath;
|
||||
|
||||
// read declaration text
|
||||
const declarationText = declarationFilePath && host.readFile(declarationFilePath);
|
||||
if (declarationFilePath && !declarationText) return declarationFilePath;
|
||||
if (declarationFilePath && BuilderState.computeSignature(declarationText!, createHash) !== buildInfo.bundle.dts!.hash) return declarationFilePath;
|
||||
if (declarationFilePath && computeSignature(declarationText!, createHash) !== buildInfo.bundle.dts!.hash) return declarationFilePath;
|
||||
const declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
|
||||
// error if no source map or for now if inline sourcemap
|
||||
if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding";
|
||||
if (declarationMapPath && BuilderState.computeSignature(declarationMapText!, createHash) !== buildInfo.bundle.dts!.mapHash) return declarationMapPath;
|
||||
if (declarationMapPath && computeSignature(declarationMapText!, createHash) !== buildInfo.bundle.dts!.mapHash) return declarationMapPath;
|
||||
|
||||
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath!, host.getCurrentDirectory()));
|
||||
const ownPrependInput = createInputFiles(
|
||||
@@ -836,8 +830,7 @@ namespace ts {
|
||||
newBuildInfo.program = buildInfo.program;
|
||||
if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
|
||||
// Update the output signature
|
||||
(newBuildInfo.program as ProgramBundleEmitBuildInfo).outSignature = computeSignature(changedDtsText, changedDtsData, createHash);
|
||||
newBuildInfo.program.dtsChangeTime = getCurrentTime(host).getTime();
|
||||
(newBuildInfo.program as ProgramBundleEmitBuildInfo).outSignature = computeSignature(changedDtsText, createHash, changedDtsData);
|
||||
}
|
||||
// Update sourceFileInfo
|
||||
const { js, dts, sourceFiles } = buildInfo.bundle!;
|
||||
|
||||
@@ -1188,7 +1188,7 @@ namespace ts {
|
||||
// @api
|
||||
function createDecorator(expression: Expression) {
|
||||
const node = createBaseNode<Decorator>(SyntaxKind.Decorator);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
||||
node.transformFlags |=
|
||||
propagateChildFlags(node.expression) |
|
||||
TransformFlags.ContainsTypeScript |
|
||||
@@ -2325,13 +2325,13 @@ namespace ts {
|
||||
// @api
|
||||
function createPropertyAccessExpression(expression: Expression, name: string | Identifier | PrivateIdentifier) {
|
||||
const node = createBaseExpression<PropertyAccessExpression>(SyntaxKind.PropertyAccessExpression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
||||
node.name = asName(name);
|
||||
node.transformFlags =
|
||||
propagateChildFlags(node.expression) |
|
||||
(isIdentifier(node.name) ?
|
||||
propagateIdentifierNameFlags(node.name) :
|
||||
propagateChildFlags(node.name));
|
||||
propagateChildFlags(node.name) | TransformFlags.ContainsPrivateIdentifierInExpression);
|
||||
if (isSuperKeyword(expression)) {
|
||||
// super method calls require a lexical 'this'
|
||||
// super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
|
||||
@@ -2357,7 +2357,7 @@ namespace ts {
|
||||
function createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier) {
|
||||
const node = createBaseExpression<PropertyAccessChain>(SyntaxKind.PropertyAccessExpression);
|
||||
node.flags |= NodeFlags.OptionalChain;
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
||||
node.questionDotToken = questionDotToken;
|
||||
node.name = asName(name);
|
||||
node.transformFlags |=
|
||||
@@ -2366,7 +2366,7 @@ namespace ts {
|
||||
propagateChildFlags(node.questionDotToken) |
|
||||
(isIdentifier(node.name) ?
|
||||
propagateIdentifierNameFlags(node.name) :
|
||||
propagateChildFlags(node.name));
|
||||
propagateChildFlags(node.name) | TransformFlags.ContainsPrivateIdentifierInExpression);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -2385,7 +2385,7 @@ namespace ts {
|
||||
// @api
|
||||
function createElementAccessExpression(expression: Expression, index: number | Expression) {
|
||||
const node = createBaseExpression<ElementAccessExpression>(SyntaxKind.ElementAccessExpression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
||||
node.argumentExpression = asExpression(index);
|
||||
node.transformFlags |=
|
||||
propagateChildFlags(node.expression) |
|
||||
@@ -2415,7 +2415,7 @@ namespace ts {
|
||||
function createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression) {
|
||||
const node = createBaseExpression<ElementAccessChain>(SyntaxKind.ElementAccessExpression);
|
||||
node.flags |= NodeFlags.OptionalChain;
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
||||
node.questionDotToken = questionDotToken;
|
||||
node.argumentExpression = asExpression(index);
|
||||
node.transformFlags |=
|
||||
@@ -2441,7 +2441,7 @@ namespace ts {
|
||||
// @api
|
||||
function createCallExpression(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined) {
|
||||
const node = createBaseExpression<CallExpression>(SyntaxKind.CallExpression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
||||
node.typeArguments = asNodeArray(typeArguments);
|
||||
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
||||
node.transformFlags |=
|
||||
@@ -2476,7 +2476,7 @@ namespace ts {
|
||||
function createCallChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined) {
|
||||
const node = createBaseExpression<CallChain>(SyntaxKind.CallExpression);
|
||||
node.flags |= NodeFlags.OptionalChain;
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
||||
node.questionDotToken = questionDotToken;
|
||||
node.typeArguments = asNodeArray(typeArguments);
|
||||
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
||||
@@ -2535,7 +2535,7 @@ namespace ts {
|
||||
// @api
|
||||
function createTaggedTemplateExpression(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral) {
|
||||
const node = createBaseExpression<TaggedTemplateExpression>(SyntaxKind.TaggedTemplateExpression);
|
||||
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
|
||||
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
|
||||
node.typeArguments = asNodeArray(typeArguments);
|
||||
node.template = template;
|
||||
node.transformFlags |=
|
||||
@@ -2851,6 +2851,9 @@ namespace ts {
|
||||
else if (isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
|
||||
node.transformFlags |= TransformFlags.ContainsES2021;
|
||||
}
|
||||
if (operatorKind === SyntaxKind.InKeyword && isPrivateIdentifier(node.left)) {
|
||||
node.transformFlags |= TransformFlags.ContainsPrivateIdentifierInExpression;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -3082,7 +3085,7 @@ namespace ts {
|
||||
// @api
|
||||
function createExpressionWithTypeArguments(expression: Expression, typeArguments: readonly TypeNode[] | undefined) {
|
||||
const node = createBaseNode<ExpressionWithTypeArguments>(SyntaxKind.ExpressionWithTypeArguments);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
||||
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
||||
node.transformFlags |=
|
||||
propagateChildFlags(node.expression) |
|
||||
@@ -3122,7 +3125,7 @@ namespace ts {
|
||||
// @api
|
||||
function createNonNullExpression(expression: Expression) {
|
||||
const node = createBaseExpression<NonNullExpression>(SyntaxKind.NonNullExpression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
||||
node.transformFlags |=
|
||||
propagateChildFlags(node.expression) |
|
||||
TransformFlags.ContainsTypeScript;
|
||||
@@ -3143,7 +3146,7 @@ namespace ts {
|
||||
function createNonNullChain(expression: Expression) {
|
||||
const node = createBaseExpression<NonNullChain>(SyntaxKind.NonNullExpression);
|
||||
node.flags |= NodeFlags.OptionalChain;
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
||||
node.transformFlags |=
|
||||
propagateChildFlags(node.expression) |
|
||||
TransformFlags.ContainsTypeScript;
|
||||
@@ -5821,7 +5824,7 @@ namespace ts {
|
||||
}
|
||||
else if (getEmitFlags(callee) & EmitFlags.HelperName) {
|
||||
thisArg = createVoidZero();
|
||||
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
|
||||
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
|
||||
}
|
||||
else if (isPropertyAccessExpression(callee)) {
|
||||
if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
|
||||
@@ -5868,7 +5871,7 @@ namespace ts {
|
||||
else {
|
||||
// for `a()` target is `a` and thisArg is `void 0`
|
||||
thisArg = createVoidZero();
|
||||
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
||||
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
||||
}
|
||||
|
||||
return { target, thisArg };
|
||||
|
||||
@@ -319,7 +319,7 @@ namespace ts {
|
||||
* Wraps an expression in parentheses if it is needed in order to use the expression for
|
||||
* property or element access.
|
||||
*/
|
||||
function parenthesizeLeftSideOfAccess(expression: Expression): LeftHandSideExpression {
|
||||
function parenthesizeLeftSideOfAccess(expression: Expression, optionalChain?: boolean): LeftHandSideExpression {
|
||||
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
||||
// to parenthesize the expression before a dot. The known exception is:
|
||||
//
|
||||
@@ -328,7 +328,8 @@ namespace ts {
|
||||
//
|
||||
const emittedExpression = skipPartiallyEmittedExpressions(expression);
|
||||
if (isLeftHandSideExpression(emittedExpression)
|
||||
&& (emittedExpression.kind !== SyntaxKind.NewExpression || (emittedExpression as NewExpression).arguments)) {
|
||||
&& (emittedExpression.kind !== SyntaxKind.NewExpression || (emittedExpression as NewExpression).arguments)
|
||||
&& (optionalChain || !isOptionalChain(emittedExpression))) {
|
||||
// TODO(rbuckton): Verify whether this assertion holds.
|
||||
return expression as LeftHandSideExpression;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace ts {
|
||||
resultFromCache?: ResolvedModuleWithFailedLookupLocations;
|
||||
packageJsonInfoCache: PackageJsonInfoCache | undefined;
|
||||
features: NodeResolutionFeatures;
|
||||
conditions: string[];
|
||||
conditions: readonly string[];
|
||||
requestContainingDirectory: string | undefined;
|
||||
reportDiagnostic: DiagnosticReporter;
|
||||
}
|
||||
@@ -486,18 +486,7 @@ namespace ts {
|
||||
host: ModuleResolutionHost,
|
||||
cache: ModuleResolutionCache | undefined,
|
||||
): PackageJsonInfo | undefined {
|
||||
const moduleResolutionState: ModuleResolutionState = {
|
||||
compilerOptions: options,
|
||||
host,
|
||||
traceEnabled: isTraceEnabled(options, host),
|
||||
failedLookupLocations: [],
|
||||
affectingLocations: [],
|
||||
packageJsonInfoCache: cache?.getPackageJsonInfoCache(),
|
||||
conditions: emptyArray,
|
||||
features: NodeResolutionFeatures.None,
|
||||
requestContainingDirectory: containingDirectory,
|
||||
reportDiagnostic: noop
|
||||
};
|
||||
const moduleResolutionState = getTemporaryModuleResolutionState(cache?.getPackageJsonInfoCache(), host, options);
|
||||
|
||||
return forEachAncestorDirectory(containingDirectory, ancestorDirectory => {
|
||||
if (getBaseFileName(ancestorDirectory) !== "node_modules") {
|
||||
@@ -554,6 +543,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache {
|
||||
/*@internal*/ clearAllExceptPackageJsonInfoCache(): void;
|
||||
}
|
||||
|
||||
export interface ModeAwareCache<T> {
|
||||
@@ -581,6 +571,7 @@ namespace ts {
|
||||
|
||||
export interface ModuleResolutionCache extends PerDirectoryResolutionCache<ResolvedModuleWithFailedLookupLocations>, NonRelativeModuleNameResolutionCache, PackageJsonInfoCache {
|
||||
getPackageJsonInfoCache(): PackageJsonInfoCache;
|
||||
/*@internal*/ clearAllExceptPackageJsonInfoCache(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -595,6 +586,7 @@ namespace ts {
|
||||
/*@internal*/ getPackageJsonInfo(packageJsonPath: string): PackageJsonInfo | boolean | undefined;
|
||||
/*@internal*/ setPackageJsonInfo(packageJsonPath: string, info: PackageJsonInfo | boolean): void;
|
||||
/*@internal*/ entries(): [Path, PackageJsonInfo | boolean][];
|
||||
/*@internal*/ getInternalMap(): ESMap<Path, PackageJsonInfo | boolean> | undefined;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
@@ -660,7 +652,7 @@ namespace ts {
|
||||
|
||||
function createPackageJsonInfoCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): PackageJsonInfoCache {
|
||||
let cache: ESMap<Path, PackageJsonInfo | boolean> | undefined;
|
||||
return { getPackageJsonInfo, setPackageJsonInfo, clear, entries };
|
||||
return { getPackageJsonInfo, setPackageJsonInfo, clear, entries, getInternalMap };
|
||||
function getPackageJsonInfo(packageJsonPath: string) {
|
||||
return cache?.get(toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
|
||||
}
|
||||
@@ -674,6 +666,9 @@ namespace ts {
|
||||
const iter = cache?.entries();
|
||||
return iter ? arrayFrom(iter) : [];
|
||||
}
|
||||
function getInternalMap() {
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
|
||||
function getOrCreateCache<T>(cacheWithRedirects: CacheWithRedirects<T>, redirectedReference: ResolvedProjectReference | undefined, key: string, create: () => T): T {
|
||||
@@ -808,25 +803,30 @@ namespace ts {
|
||||
directoryToModuleNameMap?: CacheWithRedirects<ModeAwareCache<ResolvedModuleWithFailedLookupLocations>>,
|
||||
moduleNameToDirectoryMap?: CacheWithRedirects<PerModuleNameCache>,
|
||||
): ModuleResolutionCache {
|
||||
const preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap ||= createCacheWithRedirects(options));
|
||||
const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap ||= createCacheWithRedirects(options));
|
||||
moduleNameToDirectoryMap ||= createCacheWithRedirects(options);
|
||||
const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
||||
|
||||
return {
|
||||
...packageJsonInfoCache,
|
||||
...preDirectoryResolutionCache,
|
||||
...perDirectoryResolutionCache,
|
||||
getOrCreateCacheForModuleName,
|
||||
clear,
|
||||
update,
|
||||
getPackageJsonInfoCache: () => packageJsonInfoCache,
|
||||
clearAllExceptPackageJsonInfoCache,
|
||||
};
|
||||
|
||||
function clear() {
|
||||
preDirectoryResolutionCache.clear();
|
||||
moduleNameToDirectoryMap!.clear();
|
||||
clearAllExceptPackageJsonInfoCache();
|
||||
packageJsonInfoCache.clear();
|
||||
}
|
||||
|
||||
function clearAllExceptPackageJsonInfoCache() {
|
||||
perDirectoryResolutionCache.clear();
|
||||
moduleNameToDirectoryMap!.clear();
|
||||
}
|
||||
|
||||
function update(options: CompilerOptions) {
|
||||
updateRedirectsMap(options, directoryToModuleNameMap!, moduleNameToDirectoryMap);
|
||||
}
|
||||
@@ -930,19 +930,24 @@ namespace ts {
|
||||
packageJsonInfoCache?: PackageJsonInfoCache | undefined,
|
||||
directoryToModuleNameMap?: CacheWithRedirects<ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>>,
|
||||
): TypeReferenceDirectiveResolutionCache {
|
||||
const preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap ||= createCacheWithRedirects(options));
|
||||
const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap ||= createCacheWithRedirects(options));
|
||||
packageJsonInfoCache ||= createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
||||
|
||||
return {
|
||||
...packageJsonInfoCache,
|
||||
...preDirectoryResolutionCache,
|
||||
...perDirectoryResolutionCache,
|
||||
clear,
|
||||
clearAllExceptPackageJsonInfoCache,
|
||||
};
|
||||
|
||||
function clear() {
|
||||
preDirectoryResolutionCache.clear();
|
||||
clearAllExceptPackageJsonInfoCache();
|
||||
packageJsonInfoCache!.clear();
|
||||
}
|
||||
|
||||
function clearAllExceptPackageJsonInfoCache() {
|
||||
perDirectoryResolutionCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined {
|
||||
@@ -1692,18 +1697,9 @@ namespace ts {
|
||||
let entrypoints: string[] | undefined;
|
||||
const extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
|
||||
const features = getDefaultNodeResolutionFeatures(options);
|
||||
const requireState: ModuleResolutionState = {
|
||||
compilerOptions: options,
|
||||
host,
|
||||
traceEnabled: isTraceEnabled(options, host),
|
||||
failedLookupLocations: [],
|
||||
affectingLocations: [],
|
||||
packageJsonInfoCache: cache?.getPackageJsonInfoCache(),
|
||||
conditions: ["node", "require", "types"],
|
||||
features,
|
||||
requestContainingDirectory: packageJsonInfo.packageDirectory,
|
||||
reportDiagnostic: noop
|
||||
};
|
||||
const requireState = getTemporaryModuleResolutionState(cache?.getPackageJsonInfoCache(), host, options);
|
||||
requireState.conditions = ["node", "require", "types"];
|
||||
requireState.requestContainingDirectory = packageJsonInfo.packageDirectory;
|
||||
const requireResolution = loadNodeModuleFromDirectoryWorker(
|
||||
extensions,
|
||||
packageJsonInfo.packageDirectory,
|
||||
@@ -1790,7 +1786,23 @@ namespace ts {
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
interface PackageJsonInfo {
|
||||
export function getTemporaryModuleResolutionState(packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleResolutionState {
|
||||
return {
|
||||
host,
|
||||
compilerOptions: options,
|
||||
traceEnabled: isTraceEnabled(options, host),
|
||||
failedLookupLocations: noopPush,
|
||||
affectingLocations: noopPush,
|
||||
packageJsonInfoCache,
|
||||
features: NodeResolutionFeatures.None,
|
||||
conditions: emptyArray,
|
||||
requestContainingDirectory: undefined,
|
||||
reportDiagnostic: noop
|
||||
};
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export interface PackageJsonInfo {
|
||||
packageDirectory: string;
|
||||
packageJsonContent: PackageJsonPathFields;
|
||||
versionPaths: VersionPaths | undefined;
|
||||
@@ -1802,31 +1814,7 @@ namespace ts {
|
||||
* A function for locating the package.json scope for a given path
|
||||
*/
|
||||
/*@internal*/
|
||||
export function getPackageScopeForPath(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): PackageJsonInfo | undefined {
|
||||
const state: {
|
||||
host: ModuleResolutionHost;
|
||||
compilerOptions: CompilerOptions;
|
||||
traceEnabled: boolean;
|
||||
failedLookupLocations: Push<string>;
|
||||
affectingLocations: Push<string>;
|
||||
resultFromCache?: ResolvedModuleWithFailedLookupLocations;
|
||||
packageJsonInfoCache: PackageJsonInfoCache | undefined;
|
||||
features: number;
|
||||
conditions: never[];
|
||||
requestContainingDirectory: string | undefined;
|
||||
reportDiagnostic: DiagnosticReporter
|
||||
} = {
|
||||
host,
|
||||
compilerOptions: options,
|
||||
traceEnabled: isTraceEnabled(options, host),
|
||||
failedLookupLocations: [],
|
||||
affectingLocations: [],
|
||||
packageJsonInfoCache,
|
||||
features: 0,
|
||||
conditions: [],
|
||||
requestContainingDirectory: undefined,
|
||||
reportDiagnostic: noop
|
||||
};
|
||||
export function getPackageScopeForPath(fileName: Path, state: ModuleResolutionState): PackageJsonInfo | undefined {
|
||||
const parts = getPathComponents(fileName);
|
||||
parts.pop();
|
||||
while (parts.length > 0) {
|
||||
@@ -2004,7 +1992,7 @@ namespace ts {
|
||||
function loadModuleFromSelfNameReference(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
|
||||
const useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
||||
const directoryPath = toPath(combinePaths(directory, "dummy"), state.host.getCurrentDirectory?.(), createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
|
||||
const scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
||||
const scope = getPackageScopeForPath(directoryPath, state);
|
||||
if (!scope || !scope.packageJsonContent.exports) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -2066,7 +2054,7 @@ namespace ts {
|
||||
}
|
||||
const useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
||||
const directoryPath = toPath(combinePaths(directory, "dummy"), state.host.getCurrentDirectory?.(), createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
|
||||
const scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
||||
const scope = getPackageScopeForPath(directoryPath, state);
|
||||
if (!scope) {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
|
||||
@@ -2092,10 +2080,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
|
||||
* "longest" has some nuance as to what "longest" means in the presence of pattern trailers
|
||||
*/
|
||||
function comparePatternKeys(a: string, b: string) {
|
||||
export function comparePatternKeys(a: string, b: string) {
|
||||
const aPatternIndex = a.indexOf("*");
|
||||
const bPatternIndex = b.indexOf("*");
|
||||
const baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
||||
@@ -2361,7 +2350,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function isApplicableVersionedTypesKey(conditions: string[], key: string) {
|
||||
export function isApplicableVersionedTypesKey(conditions: readonly string[], key: string) {
|
||||
if (conditions.indexOf("types") === -1) return false; // only apply versioned types conditions if the types condition is applied
|
||||
if (!startsWith(key, "types@")) return false;
|
||||
const range = VersionRange.tryParse(key.substring("types@".length));
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace ts.moduleSpecifiers {
|
||||
const info = getInfo(importingSourceFileName, host);
|
||||
const modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
||||
return firstDefined(modulePaths, modulePath => tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode)) ||
|
||||
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
||||
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
||||
}
|
||||
|
||||
export function tryGetModuleSpecifiersFromCache(
|
||||
@@ -257,7 +257,7 @@ namespace ts.moduleSpecifiers {
|
||||
}
|
||||
|
||||
if (!specifier && !modulePath.isRedirect) {
|
||||
const local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
|
||||
const local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
||||
if (pathIsBareSpecifier(local)) {
|
||||
pathsSpecifiers = append(pathsSpecifiers, local);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ namespace ts.moduleSpecifiers {
|
||||
return { getCanonicalFileName, importingSourceFileName, sourceDirectory };
|
||||
}
|
||||
|
||||
function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, { ending, relativePreference }: Preferences): string {
|
||||
function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: SourceFile["impliedNodeFormat"], { ending, relativePreference }: Preferences): string {
|
||||
const { baseUrl, paths, rootDirs } = compilerOptions;
|
||||
const { sourceDirectory, getCanonicalFileName } = info;
|
||||
const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
|
||||
@@ -308,9 +308,8 @@ namespace ts.moduleSpecifiers {
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
|
||||
const fromPaths = paths && tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
|
||||
const nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
|
||||
const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
|
||||
const nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
|
||||
if (!nonRelative) {
|
||||
return relativePath;
|
||||
}
|
||||
@@ -559,27 +558,100 @@ namespace ts.moduleSpecifiers {
|
||||
}
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex: string, relativeToBaseUrl: string, paths: MapLike<readonly string[]>): string | undefined {
|
||||
function getAllowedEndings(preferredEnding: Ending, compilerOptions: CompilerOptions, importMode: SourceFile["impliedNodeFormat"]) {
|
||||
if (getEmitModuleResolutionKind(compilerOptions) >= ModuleResolutionKind.Node16 && importMode === ModuleKind.ESNext) {
|
||||
return [Ending.JsExtension];
|
||||
}
|
||||
switch (preferredEnding) {
|
||||
case Ending.JsExtension: return [Ending.JsExtension, Ending.Minimal, Ending.Index];
|
||||
case Ending.Index: return [Ending.Index, Ending.Minimal, Ending.JsExtension];
|
||||
case Ending.Minimal: return [Ending.Minimal, Ending.Index, Ending.JsExtension];
|
||||
default: Debug.assertNever(preferredEnding);
|
||||
}
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike<readonly string[]>, allowedEndings: Ending[], host: ModuleSpecifierResolutionHost, compilerOptions: CompilerOptions): string | undefined {
|
||||
for (const key in paths) {
|
||||
for (const patternText of paths[key]) {
|
||||
const pattern = removeFileExtension(normalizePath(patternText));
|
||||
const pattern = normalizePath(patternText);
|
||||
const indexOfStar = pattern.indexOf("*");
|
||||
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
||||
// meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
|
||||
// causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
|
||||
// and matches the '*'. For example:
|
||||
//
|
||||
// Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
|
||||
// ---------------------->------------------------------->--------------------->---------------------------------------------------------------
|
||||
// import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
|
||||
// import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
|
||||
//
|
||||
// (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
|
||||
//
|
||||
// The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
|
||||
// the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
|
||||
// (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
|
||||
// extension for a module specifier.)
|
||||
//
|
||||
// Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
|
||||
// .ts extension) or the possible relative module specifiers representing that file:
|
||||
//
|
||||
// Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
|
||||
// --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
|
||||
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
|
||||
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
|
||||
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
|
||||
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js
|
||||
// dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
|
||||
//
|
||||
// The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
|
||||
// relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
|
||||
// into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
|
||||
// exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
|
||||
// specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
|
||||
// resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
|
||||
// in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
|
||||
// sorted among the others for a particular value of `importModuleSpecifierEnding`.
|
||||
const candidates: { ending: Ending | undefined, value: string }[] = allowedEndings.map(ending => ({
|
||||
ending,
|
||||
value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
|
||||
}));
|
||||
if (tryGetExtensionFromPath(pattern)) {
|
||||
candidates.push({ ending: undefined, value: relativeToBaseUrl });
|
||||
}
|
||||
|
||||
if (indexOfStar !== -1) {
|
||||
const prefix = pattern.substr(0, indexOfStar);
|
||||
const suffix = pattern.substr(indexOfStar + 1);
|
||||
if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
|
||||
startsWith(relativeToBaseUrl, prefix) &&
|
||||
endsWith(relativeToBaseUrl, suffix) ||
|
||||
!suffix && relativeToBaseUrl === removeTrailingDirectorySeparator(prefix)) {
|
||||
const matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length);
|
||||
return key.replace("*", matchedStar);
|
||||
const prefix = pattern.substring(0, indexOfStar);
|
||||
const suffix = pattern.substring(indexOfStar + 1);
|
||||
for (const { ending, value } of candidates) {
|
||||
if (value.length >= prefix.length + suffix.length &&
|
||||
startsWith(value, prefix) &&
|
||||
endsWith(value, suffix) &&
|
||||
validateEnding({ ending, value })
|
||||
) {
|
||||
const matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
||||
return key.replace("*", matchedStar);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
|
||||
else if (
|
||||
some(candidates, c => c.ending !== Ending.Minimal && pattern === c.value) ||
|
||||
some(candidates, c => c.ending === Ending.Minimal && pattern === c.value && validateEnding(c))
|
||||
) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateEnding({ ending, value }: { ending: Ending | undefined, value: string }) {
|
||||
// Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
|
||||
// is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
|
||||
// here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
|
||||
// do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the
|
||||
// `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
|
||||
// that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
|
||||
// everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
|
||||
return ending !== Ending.Minimal || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
|
||||
}
|
||||
}
|
||||
|
||||
const enum MatchingMode {
|
||||
@@ -677,10 +749,10 @@ namespace ts.moduleSpecifiers {
|
||||
|
||||
// Simplify the full file path to something that can be resolved by Node.
|
||||
|
||||
const preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
||||
let moduleSpecifier = path;
|
||||
let isPackageRootPath = false;
|
||||
if (!packageNameOnly) {
|
||||
const preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
||||
let packageRootIndex = parts.packageRootIndex;
|
||||
let moduleFileName: string | undefined;
|
||||
while (true) {
|
||||
@@ -732,15 +804,13 @@ namespace ts.moduleSpecifiers {
|
||||
const packageRootPath = path.substring(0, packageRootIndex);
|
||||
const packageJsonPath = combinePaths(packageRootPath, "package.json");
|
||||
let moduleFileToTry = path;
|
||||
let maybeBlockedByTypesVersions = false;
|
||||
const cachedPackageJson = host.getPackageJsonInfoCache?.()?.getPackageJsonInfo(packageJsonPath);
|
||||
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
||||
const packageJsonContent = cachedPackageJson?.packageJsonContent || JSON.parse(host.readFile!(packageJsonPath)!);
|
||||
const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
||||
if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext) {
|
||||
// `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
|
||||
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
||||
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
||||
// with, so for now we just stick with the mode of the file.
|
||||
const conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ModuleKind.ESNext ? "import" : "require", "types"];
|
||||
const conditions = ["node", importMode === ModuleKind.ESNext ? "import" : "require", "types"];
|
||||
const fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
||||
? tryGetModuleNameFromExports(options, path, packageRootPath, getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
||||
: undefined;
|
||||
@@ -760,19 +830,31 @@ namespace ts.moduleSpecifiers {
|
||||
if (versionPaths) {
|
||||
const subModuleName = path.slice(packageRootPath.length + 1);
|
||||
const fromPaths = tryGetModuleNameFromPaths(
|
||||
removeFileExtension(subModuleName),
|
||||
removeExtensionAndIndexPostFix(subModuleName, Ending.Minimal, options),
|
||||
versionPaths.paths
|
||||
subModuleName,
|
||||
versionPaths.paths,
|
||||
getAllowedEndings(preferences.ending, options, importMode),
|
||||
host,
|
||||
options
|
||||
);
|
||||
if (fromPaths !== undefined) {
|
||||
if (fromPaths === undefined) {
|
||||
maybeBlockedByTypesVersions = true;
|
||||
}
|
||||
else {
|
||||
moduleFileToTry = combinePaths(packageRootPath, fromPaths);
|
||||
}
|
||||
}
|
||||
// If the file is the main module, it can be imported by the package name
|
||||
const mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
||||
if (isString(mainFileRelative)) {
|
||||
if (isString(mainFileRelative) && !(maybeBlockedByTypesVersions && matchPatternOrExact(tryParsePatterns(versionPaths!.paths), mainFileRelative))) {
|
||||
// The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
|
||||
// explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
|
||||
// (The only way this can happen is if some file in a package that's not resolvable from outside the
|
||||
// package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
|
||||
// happens very easily in fourslash tests though, since every test file listed gets included. See
|
||||
// importNameCodeFix_typesVersions.ts for an example.)
|
||||
const mainExportFile = toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
||||
if (removeFileExtension(mainExportFile) === removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
||||
// ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
|
||||
return { packageRootPath, moduleFileToTry };
|
||||
}
|
||||
}
|
||||
|
||||
+42
-30
@@ -746,6 +746,8 @@ namespace ts {
|
||||
* check specified by `isFileProbablyExternalModule` will be used to set the field.
|
||||
*/
|
||||
setExternalModuleIndicator?: (file: SourceFile) => void;
|
||||
/*@internal*/ packageJsonLocations?: readonly string[];
|
||||
/*@internal*/ packageJsonScope?: PackageJsonInfo;
|
||||
}
|
||||
|
||||
function setExternalModuleIndicator(sourceFile: SourceFile) {
|
||||
@@ -2449,7 +2451,7 @@ namespace ts {
|
||||
return parseElement();
|
||||
}
|
||||
|
||||
function currentNode(parsingContext: ParsingContext): Node | undefined {
|
||||
function currentNode(parsingContext: ParsingContext, pos?: number): Node | undefined {
|
||||
// If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse.
|
||||
//
|
||||
// If there is an outstanding parse error that we've encountered, but not attached to
|
||||
@@ -2463,7 +2465,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const node = syntaxCursor.currentNode(scanner.getStartPos());
|
||||
const node = syntaxCursor.currentNode(pos ?? scanner.getStartPos());
|
||||
|
||||
// Can't reuse a missing node.
|
||||
// Can't reuse a node that intersected the change range.
|
||||
@@ -2780,7 +2782,9 @@ namespace ts {
|
||||
case ParsingContext.ImportOrExportSpecifiers: return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
||||
case ParsingContext.JsxAttributes: return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
||||
case ParsingContext.JsxChildren: return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
||||
default: return [undefined!]; // TODO: GH#18217 `default: Debug.assertNever(context);`
|
||||
case ParsingContext.AssertEntries: return parseErrorAtCurrentToken(Diagnostics.Identifier_or_string_literal_expected); // AssertionKey.
|
||||
case ParsingContext.Count: return Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker.
|
||||
default: Debug.assertNever(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3337,7 +3341,7 @@ namespace ts {
|
||||
// BindingElement[?Yield,?Await]
|
||||
|
||||
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
||||
const decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
|
||||
const decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators);
|
||||
|
||||
if (token() === SyntaxKind.ThisKeyword) {
|
||||
const node = factory.createParameterDeclaration(
|
||||
@@ -3631,11 +3635,11 @@ namespace ts {
|
||||
const hasJSDoc = hasPrecedingJSDocComment();
|
||||
const modifiers = parseModifiers();
|
||||
if (parseContextualModifier(SyntaxKind.GetKeyword)) {
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, SyntaxKind.GetAccessor);
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, SyntaxKind.GetAccessor, SignatureFlags.Type);
|
||||
}
|
||||
|
||||
if (parseContextualModifier(SyntaxKind.SetKeyword)) {
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, SyntaxKind.SetAccessor);
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, SyntaxKind.SetAccessor, SignatureFlags.Type);
|
||||
}
|
||||
|
||||
if (isIndexSignature()) {
|
||||
@@ -5285,12 +5289,15 @@ namespace ts {
|
||||
|
||||
function parseSuperExpression(): MemberExpression {
|
||||
const pos = getNodePos();
|
||||
const expression = parseTokenNode<PrimaryExpression>();
|
||||
let expression = parseTokenNode<MemberExpression>();
|
||||
if (token() === SyntaxKind.LessThanToken) {
|
||||
const startPos = getNodePos();
|
||||
const typeArguments = tryParse(parseTypeArgumentsInExpression);
|
||||
if (typeArguments !== undefined) {
|
||||
parseErrorAt(startPos, getNodePos(), Diagnostics.super_may_not_use_type_arguments);
|
||||
if (!isTemplateStartOfTaggedTemplate()) {
|
||||
expression = factory.createExpressionWithTypeArguments(expression, typeArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5646,6 +5653,11 @@ namespace ts {
|
||||
if (isOptionalChain && isPrivateIdentifier(propertyAccess.name)) {
|
||||
parseErrorAtRange(propertyAccess.name, Diagnostics.An_optional_chain_cannot_contain_private_identifiers);
|
||||
}
|
||||
if (isExpressionWithTypeArguments(expression) && expression.typeArguments) {
|
||||
const pos = expression.typeArguments.pos - 1;
|
||||
const end = skipTrivia(sourceText, expression.typeArguments.end) + 1;
|
||||
parseErrorAt(pos, end, Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access);
|
||||
}
|
||||
return finishNode(propertyAccess, pos);
|
||||
}
|
||||
|
||||
@@ -5923,10 +5935,10 @@ namespace ts {
|
||||
const modifiers = parseModifiers();
|
||||
|
||||
if (parseContextualModifier(SyntaxKind.GetKeyword)) {
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, SyntaxKind.GetAccessor);
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, SyntaxKind.GetAccessor, SignatureFlags.None);
|
||||
}
|
||||
if (parseContextualModifier(SyntaxKind.SetKeyword)) {
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, SyntaxKind.SetAccessor);
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, SyntaxKind.SetAccessor, SignatureFlags.None);
|
||||
}
|
||||
|
||||
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
@@ -6610,25 +6622,20 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseDeclaration(): Statement {
|
||||
// TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner
|
||||
// if we can't reuse the declaration, so that we don't do this work twice?
|
||||
//
|
||||
// `parseListElement` attempted to get the reused node at this position,
|
||||
// but the ambient context flag was not yet set, so the node appeared
|
||||
// not reusable in that context.
|
||||
const isAmbient = some(lookAhead(() => (parseDecorators(), parseModifiers())), isDeclareModifier);
|
||||
if (isAmbient) {
|
||||
const node = tryReuseAmbientDeclaration();
|
||||
if (node) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
const pos = getNodePos();
|
||||
const hasJSDoc = hasPrecedingJSDocComment();
|
||||
const decorators = parseDecorators();
|
||||
const modifiers = parseModifiers();
|
||||
const isAmbient = some(modifiers, isDeclareModifier);
|
||||
if (isAmbient) {
|
||||
const node = tryReuseAmbientDeclaration(pos);
|
||||
if (node) {
|
||||
return node;
|
||||
}
|
||||
|
||||
for (const m of modifiers!) {
|
||||
(m as Mutable<Node>).flags |= NodeFlags.Ambient;
|
||||
}
|
||||
@@ -6639,9 +6646,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function tryReuseAmbientDeclaration(): Statement | undefined {
|
||||
function tryReuseAmbientDeclaration(pos: number): Statement | undefined {
|
||||
return doInsideOfContext(NodeFlags.Ambient, () => {
|
||||
const node = currentNode(parsingContext);
|
||||
const node = currentNode(parsingContext, pos);
|
||||
if (node) {
|
||||
return consumeNode(node) as Statement;
|
||||
}
|
||||
@@ -6701,11 +6708,16 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseFunctionBlockOrSemicolon(flags: SignatureFlags, diagnosticMessage?: DiagnosticMessage): Block | undefined {
|
||||
if (token() !== SyntaxKind.OpenBraceToken && canParseSemicolon()) {
|
||||
parseSemicolon();
|
||||
return;
|
||||
if (token() !== SyntaxKind.OpenBraceToken) {
|
||||
if (flags & SignatureFlags.Type) {
|
||||
parseTypeMemberSemicolon();
|
||||
return;
|
||||
}
|
||||
if (canParseSemicolon()) {
|
||||
parseSemicolon();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return parseFunctionBlock(flags, diagnosticMessage);
|
||||
}
|
||||
|
||||
@@ -6972,12 +6984,12 @@ namespace ts {
|
||||
return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
|
||||
}
|
||||
|
||||
function parseAccessorDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined, kind: AccessorDeclaration["kind"]): AccessorDeclaration {
|
||||
function parseAccessorDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined, kind: AccessorDeclaration["kind"], flags: SignatureFlags): AccessorDeclaration {
|
||||
const name = parsePropertyName();
|
||||
const typeParameters = parseTypeParameters();
|
||||
const parameters = parseParameters(SignatureFlags.None);
|
||||
const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false);
|
||||
const body = parseFunctionBlockOrSemicolon(SignatureFlags.None);
|
||||
const body = parseFunctionBlockOrSemicolon(flags);
|
||||
const node = kind === SyntaxKind.GetAccessor
|
||||
? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
|
||||
: factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
|
||||
@@ -7188,11 +7200,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (parseContextualModifier(SyntaxKind.GetKeyword)) {
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, SyntaxKind.GetAccessor);
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, SyntaxKind.GetAccessor, SignatureFlags.None);
|
||||
}
|
||||
|
||||
if (parseContextualModifier(SyntaxKind.SetKeyword)) {
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, SyntaxKind.SetAccessor);
|
||||
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, SyntaxKind.SetAccessor, SignatureFlags.None);
|
||||
}
|
||||
|
||||
if (token() === SyntaxKind.ConstructorKeyword || token() === SyntaxKind.StringLiteral) {
|
||||
|
||||
+73
-50
@@ -843,6 +843,17 @@ namespace ts {
|
||||
* @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
|
||||
*/
|
||||
export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined {
|
||||
const result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options);
|
||||
return typeof result === "object" ? result.impliedNodeFormat : result;
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getImpliedNodeFormatForFileWorker(
|
||||
fileName: Path,
|
||||
packageJsonInfoCache: PackageJsonInfoCache | undefined,
|
||||
host: ModuleResolutionHost,
|
||||
options: CompilerOptions,
|
||||
) {
|
||||
switch (getEmitModuleResolutionKind(options)) {
|
||||
case ModuleResolutionKind.Node16:
|
||||
case ModuleResolutionKind.NodeNext:
|
||||
@@ -853,10 +864,14 @@ namespace ts {
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
function lookupFromPackageJson(): ModuleKind.ESNext | ModuleKind.CommonJS {
|
||||
const scope = getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
|
||||
return scope?.packageJsonContent.type === "module" ? ModuleKind.ESNext : ModuleKind.CommonJS;
|
||||
|
||||
function lookupFromPackageJson(): Partial<CreateSourceFileOptions> {
|
||||
const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
||||
const packageJsonLocations: string[] = [];
|
||||
state.failedLookupLocations = packageJsonLocations;
|
||||
state.affectingLocations = packageJsonLocations;
|
||||
const packageJsonScope = getPackageScopeForPath(fileName, state);
|
||||
const impliedNodeFormat = packageJsonScope?.packageJsonContent.type === "module" ? ModuleKind.ESNext : ModuleKind.CommonJS;
|
||||
return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1236,7 +1251,7 @@ namespace ts {
|
||||
const oldSourceFiles = oldProgram.getSourceFiles();
|
||||
for (const oldSourceFile of oldSourceFiles) {
|
||||
const newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
|
||||
if (shouldCreateNewSourceFile || !newFile ||
|
||||
if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
|
||||
// old file wasn't redirect but new file is
|
||||
(oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
|
||||
host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
|
||||
@@ -1492,7 +1507,7 @@ namespace ts {
|
||||
return classifiableNames;
|
||||
}
|
||||
|
||||
function resolveModuleNamesReusingOldState(moduleNames: string[], file: SourceFile): readonly ResolvedModuleFull[] {
|
||||
function resolveModuleNamesReusingOldState(moduleNames: string[], file: SourceFile): readonly (ResolvedModuleFull | undefined)[] {
|
||||
if (structureIsReused === StructureIsReused.Not && !file.ambientModuleNames.length) {
|
||||
// If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules,
|
||||
// the best we can do is fallback to the default logic.
|
||||
@@ -1509,10 +1524,10 @@ namespace ts {
|
||||
// which per above occurred during the current program creation.
|
||||
// Since we assume the filesystem does not change during program creation,
|
||||
// it is safe to reuse resolutions from the earlier call.
|
||||
const result: ResolvedModuleFull[] = [];
|
||||
const result: (ResolvedModuleFull | undefined)[] = [];
|
||||
let i = 0;
|
||||
for (const moduleName of moduleNames) {
|
||||
const resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i))!;
|
||||
const resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
||||
i++;
|
||||
result.push(resolvedModule);
|
||||
}
|
||||
@@ -1534,7 +1549,7 @@ namespace ts {
|
||||
* Needs to be reset to undefined before returning,
|
||||
* * ResolvedModuleFull instance: can be reused.
|
||||
*/
|
||||
let result: ResolvedModuleFull[] | undefined;
|
||||
let result: (ResolvedModuleFull | undefined)[] | undefined;
|
||||
let reusedNames: string[] | undefined;
|
||||
/** A transient placeholder used to mark predicted resolution in the result list. */
|
||||
const predictedToResolveToAmbientModuleMarker: ResolvedModuleFull = {} as any;
|
||||
@@ -1602,7 +1617,7 @@ namespace ts {
|
||||
// `result[i]` is either a `ResolvedModuleFull` or a marker.
|
||||
// If it is the former, we can leave it as is.
|
||||
if (result[i] === predictedToResolveToAmbientModuleMarker) {
|
||||
result[i] = undefined!; // TODO: GH#18217
|
||||
result[i] = undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1711,13 +1726,16 @@ namespace ts {
|
||||
const seenPackageNames = new Map<string, SeenPackageName>();
|
||||
|
||||
for (const oldSourceFile of oldSourceFiles) {
|
||||
const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
|
||||
let newSourceFile = host.getSourceFileByPath
|
||||
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile)
|
||||
: host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
|
||||
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
|
||||
: host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217
|
||||
|
||||
if (!newSourceFile) {
|
||||
return StructureIsReused.Not;
|
||||
}
|
||||
newSourceFile.packageJsonLocations = sourceFileOptions.packageJsonLocations?.length ? sourceFileOptions.packageJsonLocations : undefined;
|
||||
newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
|
||||
|
||||
Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
|
||||
|
||||
@@ -1762,43 +1780,43 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (fileChanged) {
|
||||
if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
// The `newSourceFile` object was created for the new program.
|
||||
|
||||
if (!arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
||||
else if (!arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
||||
// 'lib' references has changed. Matches behavior in changesAffectModuleResolution
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
|
||||
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
||||
else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
||||
// value of no-default-lib has changed
|
||||
// this will affect if default library is injected into the list of files
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
|
||||
// check tripleslash references
|
||||
if (!arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
||||
else if (!arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
||||
// tripleslash references has changed
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
|
||||
// check imports and module augmentations
|
||||
collectExternalModuleReferences(newSourceFile);
|
||||
if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
|
||||
// imports has changed
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
if (!arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
|
||||
// moduleAugmentations has changed
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
if ((oldSourceFile.flags & NodeFlags.PermanentlySetIncrementalFlags) !== (newSourceFile.flags & NodeFlags.PermanentlySetIncrementalFlags)) {
|
||||
// dynamicImport has changed
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
|
||||
if (!arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
|
||||
// 'types' references has changed
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
else {
|
||||
// check imports and module augmentations
|
||||
collectExternalModuleReferences(newSourceFile);
|
||||
if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
|
||||
// imports has changed
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
else if (!arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
|
||||
// moduleAugmentations has changed
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
else if ((oldSourceFile.flags & NodeFlags.PermanentlySetIncrementalFlags) !== (newSourceFile.flags & NodeFlags.PermanentlySetIncrementalFlags)) {
|
||||
// dynamicImport has changed
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
else if (!arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
|
||||
// 'types' references has changed
|
||||
structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
}
|
||||
|
||||
// tentatively approve the file
|
||||
@@ -2771,13 +2789,15 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function createRedirectSourceFile(redirectTarget: SourceFile, unredirected: SourceFile, fileName: string, path: Path, resolvedPath: Path, originalFileName: string): SourceFile {
|
||||
function createRedirectSourceFile(redirectTarget: SourceFile, unredirected: SourceFile, fileName: string, path: Path, resolvedPath: Path, originalFileName: string, sourceFileOptions: CreateSourceFileOptions): SourceFile {
|
||||
const redirect: SourceFile = Object.create(redirectTarget);
|
||||
redirect.fileName = fileName;
|
||||
redirect.path = path;
|
||||
redirect.resolvedPath = resolvedPath;
|
||||
redirect.originalFileName = originalFileName;
|
||||
redirect.redirectInfo = { redirectTarget, unredirected };
|
||||
redirect.packageJsonLocations = sourceFileOptions.packageJsonLocations?.length ? sourceFileOptions.packageJsonLocations : undefined;
|
||||
redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
|
||||
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
|
||||
Object.defineProperties(redirect, {
|
||||
id: {
|
||||
@@ -2804,16 +2824,16 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getCreateSourceFileOptions(fileName: string, moduleResolutionCache: ModuleResolutionCache | undefined, host: CompilerHost, options: CompilerOptions) {
|
||||
function getCreateSourceFileOptions(fileName: string, moduleResolutionCache: ModuleResolutionCache | undefined, host: CompilerHost, options: CompilerOptions): CreateSourceFileOptions {
|
||||
// It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
|
||||
// and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
|
||||
// to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
|
||||
const impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache?.getPackageJsonInfoCache(), host, options);
|
||||
return {
|
||||
languageVersion: getEmitScriptTarget(options),
|
||||
impliedNodeFormat,
|
||||
setExternalModuleIndicator: getSetExternalModuleIndicator(options)
|
||||
};
|
||||
const result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache?.getPackageJsonInfoCache(), host, options);
|
||||
const languageVersion = getEmitScriptTarget(options);
|
||||
const setExternalModuleIndicator = getSetExternalModuleIndicator(options);
|
||||
return typeof result === "object" ?
|
||||
{ ...result, languageVersion, setExternalModuleIndicator } :
|
||||
{ languageVersion, impliedNodeFormat: result, setExternalModuleIndicator };
|
||||
}
|
||||
|
||||
function findSourceFileWorker(fileName: string, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, reason: FileIncludeReason, packageId: PackageId | undefined): SourceFile | undefined {
|
||||
@@ -2906,11 +2926,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
const sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
|
||||
const file = host.getSourceFile(
|
||||
fileName,
|
||||
getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options),
|
||||
sourceFileOptions,
|
||||
hostErrorMessage => addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]),
|
||||
shouldCreateNewSourceFile
|
||||
shouldCreateNewSourceFile || (oldProgram?.getSourceFileByPath(toPath(fileName))?.impliedNodeFormat !== sourceFileOptions.impliedNodeFormat)
|
||||
);
|
||||
|
||||
if (packageId) {
|
||||
@@ -2919,7 +2940,7 @@ namespace ts {
|
||||
if (fileFromPackageId) {
|
||||
// Some other SourceFile already exists with this package name and version.
|
||||
// Instead of creating a duplicate, just redirect to the existing one.
|
||||
const dupFile = createRedirectSourceFile(fileFromPackageId, file!, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217
|
||||
const dupFile = createRedirectSourceFile(fileFromPackageId, file!, fileName, path, toPath(fileName), originalFileName, sourceFileOptions);
|
||||
redirectTargetsMap.add(fileFromPackageId.path, fileName);
|
||||
addFileToFilesByName(dupFile, path, redirectedPath);
|
||||
addFileIncludeReason(dupFile, reason);
|
||||
@@ -2941,6 +2962,8 @@ namespace ts {
|
||||
file.path = path;
|
||||
file.resolvedPath = toPath(fileName);
|
||||
file.originalFileName = originalFileName;
|
||||
file.packageJsonLocations = sourceFileOptions.packageJsonLocations?.length ? sourceFileOptions.packageJsonLocations : undefined;
|
||||
file.packageJsonScope = sourceFileOptions.packageJsonScope;
|
||||
addFileIncludeReason(file, reason);
|
||||
|
||||
if (host.useCaseSensitiveFileNames()) {
|
||||
@@ -3118,7 +3141,7 @@ namespace ts {
|
||||
resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined,
|
||||
reason: FileIncludeReason
|
||||
): void {
|
||||
tracing?.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
|
||||
tracing?.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
|
||||
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
|
||||
tracing?.pop();
|
||||
}
|
||||
@@ -3677,7 +3700,7 @@ namespace ts {
|
||||
if (locationReason && fileIncludeReasons?.length === 1) fileIncludeReasons = undefined;
|
||||
const location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
|
||||
const fileIncludeReasonDetails = fileIncludeReasons && chainDiagnosticMessages(fileIncludeReasons, Diagnostics.The_file_is_in_the_program_because_Colon);
|
||||
const redirectInfo = file && explainIfFileIsRedirect(file);
|
||||
const redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
|
||||
const chain = chainDiagnosticMessages(redirectInfo ? fileIncludeReasonDetails ? [fileIncludeReasonDetails, ...redirectInfo] : redirectInfo : fileIncludeReasonDetails, diagnostic, ...args || emptyArray);
|
||||
return location && isReferenceFileLocation(location) ?
|
||||
createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
|
||||
|
||||
+120
-64
@@ -20,7 +20,7 @@ namespace ts {
|
||||
|
||||
|
||||
startCachingPerDirectoryResolution(): void;
|
||||
finishCachingPerDirectoryResolution(): void;
|
||||
finishCachingPerDirectoryResolution(newProgram: Program | undefined, oldProgram: Program | undefined): void;
|
||||
|
||||
updateTypeRootsWatch(): void;
|
||||
closeTypeRootsWatch(): void;
|
||||
@@ -70,18 +70,19 @@ namespace ts {
|
||||
onDiscoveredSymlink?(): void;
|
||||
}
|
||||
|
||||
interface WatcherWithRefCount {
|
||||
interface FileWatcherOfAffectingLocation {
|
||||
/** watcher for the lookup */
|
||||
watcher: FileWatcher;
|
||||
resolutions: number;
|
||||
files: number;
|
||||
paths: Set<string>;
|
||||
}
|
||||
|
||||
interface DirectoryWatchesOfFailedLookup {
|
||||
/** watcher for the lookup */
|
||||
watcher: FileWatcher;
|
||||
/** ref count keeping this watch alive */
|
||||
refCount: number;
|
||||
}
|
||||
|
||||
interface FileWatcherOfAffectingLocation extends WatcherWithRefCount {
|
||||
paths: Set<Path>;
|
||||
}
|
||||
|
||||
interface DirectoryWatchesOfFailedLookup extends WatcherWithRefCount {
|
||||
/** is the directory watched being non recursive */
|
||||
nonRecursive?: boolean;
|
||||
}
|
||||
@@ -109,7 +110,7 @@ namespace ts {
|
||||
* "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot"
|
||||
* @param dirPath
|
||||
*/
|
||||
export function canWatchDirectory(dirPath: Path) {
|
||||
export function canWatchDirectoryOrFile(dirPath: Path) {
|
||||
const rootLength = getRootLength(dirPath);
|
||||
if (dirPath.length === rootLength) {
|
||||
// Ignore "/", "c:/"
|
||||
@@ -164,9 +165,11 @@ namespace ts {
|
||||
const resolutionsWithFailedLookups: ResolutionWithFailedLookupLocations[] = [];
|
||||
const resolutionsWithOnlyAffectingLocations: ResolutionWithFailedLookupLocations[] = [];
|
||||
const resolvedFileToResolution = createMultiMap<ResolutionWithFailedLookupLocations>();
|
||||
const impliedFormatPackageJsons = new Map<Path, readonly string[]>();
|
||||
|
||||
let hasChangedAutomaticTypeDirectiveNames = false;
|
||||
let affectingPathChecks: Set<Path> | undefined;
|
||||
let affectingPathChecksForFile: Set<string> | undefined;
|
||||
let affectingPathChecks: Set<string> | undefined;
|
||||
let failedLookupChecks: Set<Path> | undefined;
|
||||
let startsWithPathChecks: Set<Path> | undefined;
|
||||
let isInDirectoryChecks: Set<Path> | undefined;
|
||||
@@ -222,7 +225,7 @@ namespace ts {
|
||||
finishRecordingFilesWithChangedResolutions,
|
||||
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
||||
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
||||
startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
|
||||
startCachingPerDirectoryResolution,
|
||||
finishCachingPerDirectoryResolution,
|
||||
resolveModuleNames,
|
||||
getResolvedModuleWithFailedLookupLocationsFromCache,
|
||||
@@ -270,9 +273,10 @@ namespace ts {
|
||||
startsWithPathChecks = undefined;
|
||||
isInDirectoryChecks = undefined;
|
||||
affectingPathChecks = undefined;
|
||||
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
||||
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
||||
clearPerDirectoryResolutions();
|
||||
affectingPathChecksForFile = undefined;
|
||||
moduleResolutionCache.clear();
|
||||
typeReferenceDirectiveResolutionCache.clear();
|
||||
impliedFormatPackageJsons.clear();
|
||||
hasChangedAutomaticTypeDirectiveNames = false;
|
||||
}
|
||||
|
||||
@@ -310,16 +314,42 @@ namespace ts {
|
||||
isFileWithInvalidatedNonRelativeUnresolvedImports(path);
|
||||
}
|
||||
|
||||
function clearPerDirectoryResolutions() {
|
||||
moduleResolutionCache.clear();
|
||||
typeReferenceDirectiveResolutionCache.clear();
|
||||
function startCachingPerDirectoryResolution() {
|
||||
moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
|
||||
typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
|
||||
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
||||
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
||||
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
||||
nonRelativeExternalModuleResolutions.clear();
|
||||
}
|
||||
|
||||
function finishCachingPerDirectoryResolution() {
|
||||
function finishCachingPerDirectoryResolution(newProgram: Program | undefined, oldProgram: Program | undefined) {
|
||||
filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
|
||||
clearPerDirectoryResolutions();
|
||||
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
||||
nonRelativeExternalModuleResolutions.clear();
|
||||
// Update file watches
|
||||
if (newProgram !== oldProgram) {
|
||||
newProgram?.getSourceFiles().forEach(newFile => {
|
||||
const expected = isExternalOrCommonJsModule(newFile) ? newFile.packageJsonLocations?.length ?? 0 : 0;
|
||||
const existing = impliedFormatPackageJsons.get(newFile.path) ?? emptyArray;
|
||||
for (let i = existing.length; i < expected; i++) {
|
||||
createFileWatcherOfAffectingLocation(newFile.packageJsonLocations![i], /*forResolution*/ false);
|
||||
}
|
||||
if (existing.length > expected) {
|
||||
for (let i = expected; i < existing.length; i++) {
|
||||
fileWatchesOfAffectingLocations.get(existing[i])!.files--;
|
||||
}
|
||||
}
|
||||
if (expected) impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations!);
|
||||
else impliedFormatPackageJsons.delete(newFile.path);
|
||||
});
|
||||
impliedFormatPackageJsons.forEach((existing, path) => {
|
||||
if (!newProgram?.getSourceFileByPath(path)) {
|
||||
existing.forEach(location => fileWatchesOfAffectingLocations.get(location)!.files--);
|
||||
impliedFormatPackageJsons.delete(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
directoryWatchesOfFailedLookups.forEach((watcher, path) => {
|
||||
if (watcher.refCount === 0) {
|
||||
directoryWatchesOfFailedLookups.delete(path);
|
||||
@@ -327,11 +357,9 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
fileWatchesOfAffectingLocations.forEach((watcher, path) => {
|
||||
if (watcher.refCount === 0) {
|
||||
if (watcher.files === 0 && watcher.resolutions === 0) {
|
||||
fileWatchesOfAffectingLocations.delete(path);
|
||||
watcher.watcher.close();
|
||||
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
||||
watcher.watcher = noopFileWatcher;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -617,7 +645,7 @@ namespace ts {
|
||||
|
||||
// If the directory is node_modules use it to watch, always watch it recursively
|
||||
if (isNodeModulesDirectory(dirPath)) {
|
||||
return canWatchDirectory(getDirectoryPath(dirPath)) ? { dir, dirPath } : undefined;
|
||||
return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : undefined;
|
||||
}
|
||||
|
||||
let nonRecursive = true;
|
||||
@@ -637,7 +665,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : undefined;
|
||||
return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : undefined;
|
||||
}
|
||||
|
||||
function isPathWithDefaultFailedLookupExtension(path: Path) {
|
||||
@@ -714,47 +742,60 @@ namespace ts {
|
||||
if (addToResolutionsWithOnlyAffectingLocations) resolutionsWithOnlyAffectingLocations.push(resolution);
|
||||
// Watch package json
|
||||
for (const affectingLocation of affectingLocations) {
|
||||
createFileWatcherOfAffectingLocation(affectingLocation);
|
||||
createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
function createFileWatcherOfAffectingLocation(affectingLocation: string) {
|
||||
const path = resolutionHost.toPath(affectingLocation);
|
||||
const fileWatcher = fileWatchesOfAffectingLocations.get(path);
|
||||
function createFileWatcherOfAffectingLocation(affectingLocation: string, forResolution: boolean) {
|
||||
const fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
||||
if (fileWatcher) {
|
||||
fileWatcher.refCount++;
|
||||
if (forResolution) fileWatcher.resolutions++;
|
||||
else fileWatcher.files++;
|
||||
return;
|
||||
}
|
||||
let locationToWatch = affectingLocation;
|
||||
let locationToWatchPath = path;
|
||||
if (resolutionHost.realpath) {
|
||||
locationToWatch = resolutionHost.realpath(affectingLocation);
|
||||
locationToWatchPath = resolutionHost.toPath(locationToWatch);
|
||||
if (path !== locationToWatchPath) {
|
||||
const fileWatcher = fileWatchesOfAffectingLocations.get(locationToWatchPath);
|
||||
if (affectingLocation !== locationToWatch) {
|
||||
const fileWatcher = fileWatchesOfAffectingLocations.get(locationToWatch);
|
||||
if (fileWatcher) {
|
||||
fileWatcher.refCount++;
|
||||
fileWatcher.paths.add(path);
|
||||
fileWatchesOfAffectingLocations.set(path, fileWatcher);
|
||||
if (forResolution) fileWatcher.resolutions++;
|
||||
else fileWatcher.files++;
|
||||
fileWatcher.paths.add(affectingLocation);
|
||||
fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
const paths = new Set<Path>();
|
||||
paths.add(locationToWatchPath);
|
||||
const watcher: FileWatcherOfAffectingLocation = {
|
||||
watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
|
||||
cachedDirectoryStructureHost?.addOrDeleteFile(fileName, path, eventKind);
|
||||
paths.forEach(path => (affectingPathChecks ||= new Set()).add(path));
|
||||
const paths = new Set<string>();
|
||||
paths.add(locationToWatch);
|
||||
let actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
|
||||
resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
|
||||
cachedDirectoryStructureHost?.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
||||
const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
||||
paths.forEach(path => {
|
||||
if (watcher.resolutions) (affectingPathChecks ??= new Set()).add(path);
|
||||
if (watcher.files) (affectingPathChecksForFile ??= new Set()).add(path);
|
||||
packageJsonMap?.delete(resolutionHost.toPath(path));
|
||||
});
|
||||
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
||||
}),
|
||||
refCount: 1,
|
||||
}) : noopFileWatcher;
|
||||
const watcher: FileWatcherOfAffectingLocation = {
|
||||
watcher: actualWatcher !== noopFileWatcher ? {
|
||||
close: () => {
|
||||
actualWatcher.close();
|
||||
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
||||
actualWatcher = noopFileWatcher;
|
||||
}
|
||||
} : actualWatcher,
|
||||
resolutions: forResolution ? 1 : 0,
|
||||
files: forResolution ? 0 : 1,
|
||||
paths,
|
||||
};
|
||||
fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher);
|
||||
if (path !== locationToWatchPath) {
|
||||
fileWatchesOfAffectingLocations.set(path, watcher);
|
||||
paths.add(path);
|
||||
fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
|
||||
if (affectingLocation !== locationToWatch) {
|
||||
fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
|
||||
paths.add(affectingLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -830,8 +871,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
for (const affectingLocation of affectingLocations) {
|
||||
const watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation))!;
|
||||
watcher.refCount--;
|
||||
const watcher = fileWatchesOfAffectingLocations.get(affectingLocation)!;
|
||||
watcher.resolutions--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -892,7 +933,7 @@ namespace ts {
|
||||
if (resolution.isInvalidated || !canInvalidate(resolution)) continue;
|
||||
resolution.isInvalidated = invalidated = true;
|
||||
for (const containingFilePath of Debug.checkDefined(resolution.files)) {
|
||||
(filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new Set())).add(containingFilePath);
|
||||
(filesWithInvalidatedResolutions ??= new Set()).add(containingFilePath);
|
||||
// When its a file with inferred types resolution, invalidate type reference directive resolution
|
||||
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);
|
||||
}
|
||||
@@ -964,11 +1005,26 @@ namespace ts {
|
||||
}
|
||||
|
||||
function invalidateResolutionsOfFailedLookupLocations() {
|
||||
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
|
||||
return false;
|
||||
let invalidated = false;
|
||||
if (affectingPathChecksForFile) {
|
||||
resolutionHost.getCurrentProgram()?.getSourceFiles().forEach(f => {
|
||||
if (some(f.packageJsonLocations, location => affectingPathChecksForFile!.has(location))) {
|
||||
(filesWithInvalidatedResolutions ??= new Set()).add(f.path);
|
||||
invalidated = true;
|
||||
}
|
||||
});
|
||||
affectingPathChecksForFile = undefined;
|
||||
}
|
||||
|
||||
let invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
|
||||
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
|
||||
return invalidated;
|
||||
}
|
||||
|
||||
invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
|
||||
const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
||||
if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
|
||||
packageJsonMap.forEach((_value, path) => isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined);
|
||||
}
|
||||
failedLookupChecks = undefined;
|
||||
startsWithPathChecks = undefined;
|
||||
isInDirectoryChecks = undefined;
|
||||
@@ -980,17 +1036,17 @@ namespace ts {
|
||||
function canInvalidateFailedLookupResolution(resolution: ResolutionWithFailedLookupLocations) {
|
||||
if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution)) return true;
|
||||
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false;
|
||||
return resolution.failedLookupLocations.some(location => {
|
||||
const locationPath = resolutionHost.toPath(location);
|
||||
return failedLookupChecks?.has(locationPath) ||
|
||||
firstDefinedIterator(startsWithPathChecks?.keys() || emptyIterator, fileOrDirectoryPath => startsWith(locationPath, fileOrDirectoryPath) ? true : undefined) ||
|
||||
firstDefinedIterator(isInDirectoryChecks?.keys() || emptyIterator, fileOrDirectoryPath => isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined);
|
||||
});
|
||||
return resolution.failedLookupLocations.some(location => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
|
||||
}
|
||||
|
||||
function isInvalidatedFailedLookup(locationPath: Path) {
|
||||
return failedLookupChecks?.has(locationPath) ||
|
||||
firstDefinedIterator(startsWithPathChecks?.keys() || emptyIterator, fileOrDirectoryPath => startsWith(locationPath, fileOrDirectoryPath) ? true : undefined) ||
|
||||
firstDefinedIterator(isInDirectoryChecks?.keys() || emptyIterator, fileOrDirectoryPath => isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined);
|
||||
}
|
||||
|
||||
function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution: ResolutionWithFailedLookupLocations) {
|
||||
return !!affectingPathChecks && resolution.affectingLocations.some(location =>
|
||||
affectingPathChecks!.has(resolutionHost.toPath(location)));
|
||||
return !!affectingPathChecks && resolution.affectingLocations.some(location => affectingPathChecks!.has(location));
|
||||
}
|
||||
|
||||
function closeTypeRootsWatch() {
|
||||
@@ -1068,7 +1124,7 @@ namespace ts {
|
||||
function directoryExistsForTypeRootWatch(nodeTypesDirectory: string) {
|
||||
const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
|
||||
const dirPath = resolutionHost.toPath(dir);
|
||||
return dirPath === rootPath || canWatchDirectory(dirPath);
|
||||
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -1088,14 +1088,16 @@ namespace ts {
|
||||
lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(directorySeparator.length);
|
||||
}
|
||||
/** Watcher for the file system entry depending on whether it is missing or present */
|
||||
let watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
||||
let watcher: FileWatcher | undefined = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
||||
watchMissingFileSystemEntry() :
|
||||
watchPresentFileSystemEntry();
|
||||
return {
|
||||
close: () => {
|
||||
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
||||
watcher.close();
|
||||
watcher = undefined!;
|
||||
if (watcher) {
|
||||
watcher.close();
|
||||
watcher = undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -131,9 +131,9 @@ namespace ts { // eslint-disable-line one-namespace-per-file
|
||||
}
|
||||
eventStack.push({ phase, name, args, time: 1000 * timestamp(), separateBeginAndEnd });
|
||||
}
|
||||
export function pop() {
|
||||
export function pop(results?: Args) {
|
||||
Debug.assert(eventStack.length > 0);
|
||||
writeStackEvent(eventStack.length - 1, 1000 * timestamp());
|
||||
writeStackEvent(eventStack.length - 1, 1000 * timestamp(), results);
|
||||
eventStack.length--;
|
||||
}
|
||||
export function popAll() {
|
||||
@@ -145,14 +145,15 @@ namespace ts { // eslint-disable-line one-namespace-per-file
|
||||
}
|
||||
// sample every 10ms
|
||||
const sampleInterval = 1000 * 10;
|
||||
function writeStackEvent(index: number, endTime: number) {
|
||||
function writeStackEvent(index: number, endTime: number, results?: Args) {
|
||||
const { phase, name, args, time, separateBeginAndEnd } = eventStack[index];
|
||||
if (separateBeginAndEnd) {
|
||||
Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`");
|
||||
writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
|
||||
}
|
||||
// test if [time,endTime) straddles a sampling point
|
||||
else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
|
||||
writeEvent("X", phase, name, args, `"dur":${endTime - time}`, time);
|
||||
writeEvent("X", phase, name, { ...args, results }, `"dur":${endTime - time}`, time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -576,10 +576,11 @@ namespace ts {
|
||||
|
||||
function visitPreOrPostfixUnaryExpression(node: PrefixUnaryExpression | PostfixUnaryExpression, valueIsDiscarded: boolean) {
|
||||
if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) {
|
||||
if (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifierPropertyAccessExpression(node.operand)) {
|
||||
const operand = skipParentheses(node.operand);
|
||||
if (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifierPropertyAccessExpression(operand)) {
|
||||
let info: PrivateIdentifierInfo | undefined;
|
||||
if (info = accessPrivateIdentifier(node.operand.name)) {
|
||||
const receiver = visitNode(node.operand.expression, visitor, isExpression);
|
||||
if (info = accessPrivateIdentifier(operand.name)) {
|
||||
const receiver = visitNode(operand.expression, visitor, isExpression);
|
||||
const { readExpression, initializeExpression } = createCopiableReceiverExpr(receiver);
|
||||
|
||||
let expression: Expression = createPrivateIdentifierAccess(info, readExpression);
|
||||
@@ -601,7 +602,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (shouldTransformSuperInStaticInitializers &&
|
||||
isSuperProperty(node.operand) &&
|
||||
isSuperProperty(operand) &&
|
||||
currentStaticPropertyDeclarationOrStaticBlock &&
|
||||
currentClassLexicalEnvironment) {
|
||||
// converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)`
|
||||
@@ -614,31 +615,31 @@ namespace ts {
|
||||
// converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)`
|
||||
const { classConstructor, superClassReference, facts } = currentClassLexicalEnvironment;
|
||||
if (facts & ClassFacts.ClassWasDecorated) {
|
||||
const operand = visitInvalidSuperProperty(node.operand);
|
||||
const expression = visitInvalidSuperProperty(operand);
|
||||
return isPrefixUnaryExpression(node) ?
|
||||
factory.updatePrefixUnaryExpression(node, operand) :
|
||||
factory.updatePostfixUnaryExpression(node, operand);
|
||||
factory.updatePrefixUnaryExpression(node, expression) :
|
||||
factory.updatePostfixUnaryExpression(node, expression);
|
||||
}
|
||||
if (classConstructor && superClassReference) {
|
||||
let setterName: Expression | undefined;
|
||||
let getterName: Expression | undefined;
|
||||
if (isPropertyAccessExpression(node.operand)) {
|
||||
if (isIdentifier(node.operand.name)) {
|
||||
getterName = setterName = factory.createStringLiteralFromNode(node.operand.name);
|
||||
if (isPropertyAccessExpression(operand)) {
|
||||
if (isIdentifier(operand.name)) {
|
||||
getterName = setterName = factory.createStringLiteralFromNode(operand.name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isSimpleInlineableExpression(node.operand.argumentExpression)) {
|
||||
getterName = setterName = node.operand.argumentExpression;
|
||||
if (isSimpleInlineableExpression(operand.argumentExpression)) {
|
||||
getterName = setterName = operand.argumentExpression;
|
||||
}
|
||||
else {
|
||||
getterName = factory.createTempVariable(hoistVariableDeclaration);
|
||||
setterName = factory.createAssignment(getterName, visitNode(node.operand.argumentExpression, visitor, isExpression));
|
||||
setterName = factory.createAssignment(getterName, visitNode(operand.argumentExpression, visitor, isExpression));
|
||||
}
|
||||
}
|
||||
if (setterName && getterName) {
|
||||
let expression: Expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor);
|
||||
setTextRange(expression, node.operand);
|
||||
setTextRange(expression, operand);
|
||||
|
||||
const temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
|
||||
expression = expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp);
|
||||
|
||||
@@ -68,52 +68,88 @@ namespace ts {
|
||||
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
|
||||
if (!(classOrConstructorParameterIsDecorated(node) || childIsDecorated(node))) return visitEachChild(node, visitor, context);
|
||||
|
||||
const classStatement = hasDecorators(node) ?
|
||||
createClassDeclarationHeadWithDecorators(node, node.name) :
|
||||
createClassDeclarationHeadWithoutDecorators(node, node.name);
|
||||
|
||||
const statements: Statement[] = [classStatement];
|
||||
|
||||
// Write any decorators of the node.
|
||||
addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
|
||||
addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
|
||||
addConstructorDecorationStatement(statements, node);
|
||||
const statements = hasDecorators(node) ?
|
||||
transformClassDeclarationWithClassDecorators(node, node.name) :
|
||||
transformClassDeclarationWithoutClassDecorators(node, node.name);
|
||||
|
||||
if (statements.length > 1) {
|
||||
// Add a DeclarationMarker as a marker for the end of the declaration
|
||||
statements.push(factory.createEndOfDeclarationMarker(node));
|
||||
setEmitFlags(classStatement, getEmitFlags(classStatement) | EmitFlags.HasEndOfDeclarationMarker);
|
||||
setEmitFlags(statements[0], getEmitFlags(statements[0]) | EmitFlags.HasEndOfDeclarationMarker);
|
||||
}
|
||||
|
||||
return singleOrMany(statements);
|
||||
}
|
||||
|
||||
function decoratorContainsPrivateIdentifierInExpression(decorator: Decorator) {
|
||||
return !!(decorator.transformFlags & TransformFlags.ContainsPrivateIdentifierInExpression);
|
||||
}
|
||||
|
||||
function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators: readonly Decorator[] | undefined) {
|
||||
return some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression);
|
||||
}
|
||||
|
||||
function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node: ClassDeclaration) {
|
||||
for (const member of node.members) {
|
||||
if (!canHaveDecorators(member)) continue;
|
||||
const allDecorators = getAllDecoratorsOfClassElement(member, node);
|
||||
if (some(allDecorators?.decorators, decoratorContainsPrivateIdentifierInExpression)) return true;
|
||||
if (some(allDecorators?.parameters, parameterDecoratorsContainPrivateIdentifierInExpression)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function transformDecoratorsOfClassElements(node: ClassDeclaration, members: NodeArray<ClassElement>) {
|
||||
let decorationStatements: Statement[] | undefined = [];
|
||||
addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false);
|
||||
addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true);
|
||||
if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) {
|
||||
members = setTextRange(factory.createNodeArray([
|
||||
...members,
|
||||
factory.createClassStaticBlockDeclaration(
|
||||
factory.createBlock(decorationStatements, /*multiLine*/ true)
|
||||
)
|
||||
]), members);
|
||||
decorationStatements = undefined;
|
||||
}
|
||||
return { decorationStatements, members };
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a non-decorated class declaration.
|
||||
*
|
||||
* @param node A ClassDeclaration node.
|
||||
* @param name The name of the class.
|
||||
*/
|
||||
function createClassDeclarationHeadWithoutDecorators(node: ClassDeclaration, name: Identifier | undefined) {
|
||||
function transformClassDeclarationWithoutClassDecorators(node: ClassDeclaration, name: Identifier | undefined) {
|
||||
// ${modifiers} class ${name} ${heritageClauses} {
|
||||
// ${members}
|
||||
// }
|
||||
|
||||
return factory.updateClassDeclaration(
|
||||
const modifiers = visitNodes(node.modifiers, modifierVisitor, isModifier);
|
||||
const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause);
|
||||
let members = visitNodes(node.members, visitor, isClassElement);
|
||||
|
||||
let decorationStatements: Statement[] | undefined = [];
|
||||
({ members, decorationStatements } = transformDecoratorsOfClassElements(node, members));
|
||||
|
||||
const updated = factory.updateClassDeclaration(
|
||||
node,
|
||||
visitNodes(node.modifiers, modifierVisitor, isModifier),
|
||||
modifiers,
|
||||
name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitNodes(node.heritageClauses, visitor, isHeritageClause),
|
||||
visitNodes(node.members, visitor, isClassElement)
|
||||
heritageClauses,
|
||||
members
|
||||
);
|
||||
|
||||
return addRange([updated], decorationStatements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a decorated class declaration and appends the resulting statements. If
|
||||
* the class requires an alias to avoid issues with double-binding, the alias is returned.
|
||||
*/
|
||||
function createClassDeclarationHeadWithDecorators(node: ClassDeclaration, name: Identifier | undefined) {
|
||||
function transformClassDeclarationWithClassDecorators(node: ClassDeclaration, name: Identifier | undefined) {
|
||||
// When we emit an ES6 class that has a class decorator, we must tailor the
|
||||
// emit to certain specific cases.
|
||||
//
|
||||
@@ -213,8 +249,18 @@ namespace ts {
|
||||
// ${members}
|
||||
// }
|
||||
const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause);
|
||||
const members = visitNodes(node.members, visitor, isClassElement);
|
||||
const classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
|
||||
let members = visitNodes(node.members, visitor, isClassElement);
|
||||
|
||||
let decorationStatements: Statement[] | undefined = [];
|
||||
({ members, decorationStatements } = transformDecoratorsOfClassElements(node, members));
|
||||
|
||||
const classExpression = factory.createClassExpression(
|
||||
/*modifiers*/ undefined,
|
||||
name,
|
||||
/*typeParameters*/ undefined,
|
||||
heritageClauses,
|
||||
members);
|
||||
|
||||
setOriginalNode(classExpression, node);
|
||||
setTextRange(classExpression, location);
|
||||
|
||||
@@ -234,7 +280,11 @@ namespace ts {
|
||||
setOriginalNode(statement, node);
|
||||
setTextRange(statement, location);
|
||||
setCommentRange(statement, node);
|
||||
return statement;
|
||||
|
||||
const statements: Statement[] = [statement];
|
||||
addRange(statements, decorationStatements);
|
||||
addConstructorDecorationStatement(statements, node);
|
||||
return statements;
|
||||
}
|
||||
|
||||
function visitClassExpression(node: ClassExpression) {
|
||||
|
||||
@@ -1113,7 +1113,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
||||
addRange(statements, visitNodes(body.statements, visitor, isStatement, superStatementIndex + 1 + prologueStatementCount));
|
||||
const start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
|
||||
addRange(statements, visitNodes(body.statements, visitor, isStatement, start));
|
||||
|
||||
// End the lexical environment.
|
||||
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
||||
|
||||
@@ -72,7 +72,6 @@ namespace ts {
|
||||
type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes | UpToDateStatusType.UpToDateWithInputFileText;
|
||||
newestInputFileTime?: Date;
|
||||
newestInputFileName?: string;
|
||||
newestDeclarationFileContentChangedTime: Date | undefined;
|
||||
oldestOutputFileName: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -224,6 +224,7 @@ namespace ts {
|
||||
path: Path;
|
||||
buildInfo: BuildInfo | false;
|
||||
modifiedTime: Date;
|
||||
latestChangedDtsTime?: Date | false;
|
||||
}
|
||||
|
||||
interface SolutionBuilderState<T extends BuilderProgram = BuilderProgram> extends WatchFactory<WatchType, ResolvedConfigFileName> {
|
||||
@@ -295,6 +296,7 @@ namespace ts {
|
||||
compilerHost.getParsedCommandLine = fileName => parseConfigFile(state, fileName as ResolvedConfigFileName, toResolvedConfigFilePath(state, fileName as ResolvedConfigFileName));
|
||||
compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
|
||||
compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
|
||||
compilerHost.getModuleResolutionCache = maybeBind(host, host.getModuleResolutionCache);
|
||||
const moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
||||
const typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache?.getPackageJsonInfoCache()) : undefined;
|
||||
if (!compilerHost.resolveModuleNames) {
|
||||
@@ -980,8 +982,7 @@ namespace ts {
|
||||
|
||||
// Actual Emit
|
||||
const { host, compilerHost } = state;
|
||||
let resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
|
||||
const existingBuildInfo = state.buildInfoCache.get(projectPath)?.buildInfo || undefined;
|
||||
const resultFlags = program.hasChangedEmitSignature?.() ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged;
|
||||
const emitterDiagnostics = createDiagnosticCollection();
|
||||
const emittedOutputs = new Map<Path, string>();
|
||||
const options = program.getCompilerOptions();
|
||||
@@ -991,13 +992,7 @@ namespace ts {
|
||||
outputFiles.forEach(({ name, text, writeByteOrderMark, buildInfo }) => {
|
||||
const path = toPath(state, name);
|
||||
emittedOutputs.set(toPath(state, name), name);
|
||||
if (buildInfo) {
|
||||
setBuildInfo(state, buildInfo, projectPath, options);
|
||||
// Buildinfo has information on when last dts change time
|
||||
if (buildInfo.program?.dtsChangeTime !== existingBuildInfo?.program?.dtsChangeTime) {
|
||||
resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
|
||||
}
|
||||
}
|
||||
if (buildInfo) setBuildInfo(state, buildInfo, projectPath, options, resultFlags);
|
||||
writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
|
||||
if (!isIncremental && state.watch) {
|
||||
(outputTimeStampMap ||= getOutputTimeStampMap(state, projectPath)!).set(path, now ||= getCurrentTime(state.host));
|
||||
@@ -1017,7 +1012,7 @@ namespace ts {
|
||||
Debug.assertIsDefined(program);
|
||||
Debug.assert(step === BuildStep.EmitBuildInfo);
|
||||
const emitResult = program.emitBuildInfo((name, text, writeByteOrderMark, onError, sourceFiles, data) => {
|
||||
if (data?.buildInfo) setBuildInfo(state, data.buildInfo, projectPath, program!.getCompilerOptions());
|
||||
if (data?.buildInfo) setBuildInfo(state, data.buildInfo, projectPath, program!.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged);
|
||||
if (writeFileCallback) writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data);
|
||||
else state.compilerHost.writeFile(name, text, writeByteOrderMark, onError, sourceFiles, data);
|
||||
}, cancellationToken);
|
||||
@@ -1064,7 +1059,6 @@ namespace ts {
|
||||
state.diagnostics.delete(projectPath);
|
||||
state.projectStatus.set(projectPath, {
|
||||
type: UpToDateStatusType.UpToDate,
|
||||
newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath)!,
|
||||
oldestOutputFileName
|
||||
});
|
||||
afterProgramDone(state, program, config);
|
||||
@@ -1120,10 +1114,10 @@ namespace ts {
|
||||
outputFiles.forEach(({ name, text, writeByteOrderMark, buildInfo }) => {
|
||||
emittedOutputs.set(toPath(state, name), name);
|
||||
if (buildInfo) {
|
||||
setBuildInfo(state, buildInfo, projectPath, config.options);
|
||||
if (buildInfo.program?.dtsChangeTime !== existingBuildInfo.program?.dtsChangeTime) {
|
||||
if ((buildInfo.program as ProgramBundleEmitBuildInfo)?.outSignature !== (existingBuildInfo.program as ProgramBundleEmitBuildInfo)?.outSignature) {
|
||||
resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
|
||||
}
|
||||
setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
|
||||
}
|
||||
writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
|
||||
});
|
||||
@@ -1365,7 +1359,7 @@ namespace ts {
|
||||
config: ParsedCommandLine
|
||||
) {
|
||||
if (program) {
|
||||
if (program && state.write) listFiles(program, state.write);
|
||||
if (state.write) listFiles(program, state.write);
|
||||
if (state.host.afterProgramEmitAndDiagnostics) {
|
||||
state.host.afterProgramEmitAndDiagnostics(program);
|
||||
}
|
||||
@@ -1464,15 +1458,28 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function setBuildInfo(state: SolutionBuilderState, buildInfo: BuildInfo, resolvedConfigPath: ResolvedConfigFilePath, options: CompilerOptions) {
|
||||
function setBuildInfo(
|
||||
state: SolutionBuilderState,
|
||||
buildInfo: BuildInfo,
|
||||
resolvedConfigPath: ResolvedConfigFilePath,
|
||||
options: CompilerOptions,
|
||||
resultFlags: BuildResultFlags,
|
||||
) {
|
||||
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options)!;
|
||||
const existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
|
||||
const modifiedTime = getCurrentTime(state.host);
|
||||
if (existing) {
|
||||
existing.buildInfo = buildInfo;
|
||||
existing.modifiedTime = getCurrentTime(state.host);
|
||||
existing.modifiedTime = modifiedTime;
|
||||
if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged)) existing.latestChangedDtsTime = modifiedTime;
|
||||
}
|
||||
else {
|
||||
state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo, modifiedTime: getCurrentTime(state.host) });
|
||||
state.buildInfoCache.set(resolvedConfigPath, {
|
||||
path: toPath(state, buildInfoPath),
|
||||
buildInfo,
|
||||
modifiedTime,
|
||||
latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1563,7 +1570,6 @@ namespace ts {
|
||||
let buildInfoTime: Date | undefined;
|
||||
let buildInfoProgram: ProgramBuildInfo | undefined;
|
||||
let buildInfoVersionMap: ESMap<Path, string> | undefined;
|
||||
let newestDeclarationFileContentChangedTime;
|
||||
if (buildInfoPath) {
|
||||
const buildInfoCacheEntry = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath);
|
||||
buildInfoTime = buildInfoCacheEntry?.modifiedTime || ts.getModifiedTime(host, buildInfoPath);
|
||||
@@ -1603,8 +1609,6 @@ namespace ts {
|
||||
|
||||
oldestOutputFileTime = buildInfoTime;
|
||||
oldestOutputFileName = buildInfoPath;
|
||||
// Get the last dtsChange time from build info
|
||||
newestDeclarationFileContentChangedTime = buildInfo.program?.dtsChangeTime ? new Date(buildInfo.program.dtsChangeTime) : undefined;
|
||||
}
|
||||
|
||||
// Check input files
|
||||
@@ -1718,7 +1722,8 @@ namespace ts {
|
||||
|
||||
// If the upstream project has only change .d.ts files, and we've built
|
||||
// *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
|
||||
if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
|
||||
const newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath);
|
||||
if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
|
||||
pseudoUpToDate = true;
|
||||
upstreamChangedProject = ref.path;
|
||||
continue;
|
||||
@@ -1764,7 +1769,6 @@ namespace ts {
|
||||
pseudoInputUpToDate ?
|
||||
UpToDateStatusType.UpToDateWithInputFileText :
|
||||
UpToDateStatusType.UpToDate,
|
||||
newestDeclarationFileContentChangedTime,
|
||||
newestInputFileTime,
|
||||
newestInputFileName,
|
||||
oldestOutputFileName: oldestOutputFileName!
|
||||
@@ -1854,11 +1858,15 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getDtsChangeTime(state: SolutionBuilderState, options: CompilerOptions, resolvedConfigPath: ResolvedConfigFilePath) {
|
||||
function getLatestChangedDtsTime(state: SolutionBuilderState, options: CompilerOptions, resolvedConfigPath: ResolvedConfigFilePath) {
|
||||
if (!options.composite) return undefined;
|
||||
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options)!;
|
||||
const buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined);
|
||||
return buildInfo?.program?.dtsChangeTime ? new Date(buildInfo.program.dtsChangeTime) : undefined;
|
||||
const entry = Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath));
|
||||
if (entry.latestChangedDtsTime !== undefined) return entry.latestChangedDtsTime || undefined;
|
||||
const latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ?
|
||||
state.host.getModifiedTime(getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, getDirectoryPath(entry.path))) :
|
||||
undefined;
|
||||
entry.latestChangedDtsTime = latestChangedDtsTime || false;
|
||||
return latestChangedDtsTime;
|
||||
}
|
||||
|
||||
function updateOutputTimestamps(state: SolutionBuilderState, proj: ParsedCommandLine, resolvedPath: ResolvedConfigFilePath) {
|
||||
@@ -1868,7 +1876,6 @@ namespace ts {
|
||||
updateOutputTimestampsWorker(state, proj, resolvedPath, Diagnostics.Updating_output_timestamps_of_project_0);
|
||||
state.projectStatus.set(resolvedPath, {
|
||||
type: UpToDateStatusType.UpToDate,
|
||||
newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
|
||||
oldestOutputFileName: getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
|
||||
});
|
||||
}
|
||||
|
||||
+27
-10
@@ -3791,8 +3791,16 @@ namespace ts {
|
||||
* It is _public_ so that (pre)transformers can set this field,
|
||||
* since it switches the builtin `node` module transform. Generally speaking, if unset,
|
||||
* the field is treated as though it is `ModuleKind.CommonJS`.
|
||||
*
|
||||
* Note that this field is only set by the module resolution process when
|
||||
* `moduleResolution` is `Node16` or `NodeNext`, which is implied by the `module` setting
|
||||
* of `Node16` or `NodeNext`, respectively, but may be overriden (eg, by a `moduleResolution`
|
||||
* of `node`). If so, this field will be unset and source files will be considered to be
|
||||
* CommonJS-output-format by the node module transformer and type checker, regardless of extension or context.
|
||||
*/
|
||||
impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS;
|
||||
/*@internal*/ packageJsonLocations?: readonly string[];
|
||||
/*@internal*/ packageJsonScope?: PackageJsonInfo;
|
||||
|
||||
/* @internal */ scriptKind: ScriptKind;
|
||||
|
||||
@@ -4026,6 +4034,7 @@ namespace ts {
|
||||
export interface WriteFileCallbackData {
|
||||
/*@internal*/ sourceMapUrlPos?: number;
|
||||
/*@internal*/ buildInfo?: BuildInfo;
|
||||
/*@internal*/ diagnostics?: readonly DiagnosticWithLocation[];
|
||||
}
|
||||
export type WriteFileCallback = (
|
||||
fileName: string,
|
||||
@@ -4335,7 +4344,6 @@ namespace ts {
|
||||
diagnostics: readonly Diagnostic[];
|
||||
emittedFiles?: string[]; // Array of files the compiler wrote to disk
|
||||
/* @internal */ sourceMaps?: SourceMapEmitResult[]; // Array of sourceMapData if compiler emitted sourcemaps
|
||||
/* @internal */ exportedModulesFromDeclarationEmit?: ExportedModulesFromDeclarationEmit;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -4664,10 +4672,11 @@ namespace ts {
|
||||
UseAliasDefinedOutsideCurrentScope = 1 << 14, // Allow non-visible aliases
|
||||
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
|
||||
NoTypeReduction = 1 << 29, // Don't call getReducedType
|
||||
OmitThisParameter = 1 << 25,
|
||||
|
||||
// Error handling
|
||||
AllowThisInObjectLiteral = 1 << 15,
|
||||
AllowQualifiedNameInPlaceOfIdentifier = 1 << 16,
|
||||
AllowQualifiedNameInPlaceOfIdentifier = 1 << 16,
|
||||
/** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */
|
||||
AllowQualifedNameInPlaceOfIdentifier = AllowQualifiedNameInPlaceOfIdentifier,
|
||||
AllowAnonymousIdentifier = 1 << 17,
|
||||
@@ -4709,6 +4718,7 @@ namespace ts {
|
||||
UseAliasDefinedOutsideCurrentScope = 1 << 14, // For a `type T = ... ` defined in a different file, write `T` instead of its value, even though `T` can't be accessed in the current scope.
|
||||
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
|
||||
NoTypeReduction = 1 << 29, // Don't call getReducedType
|
||||
OmitThisParameter = 1 << 25,
|
||||
|
||||
// Error Handling
|
||||
AllowUniqueESSymbolType = 1 << 20, // This is bit 20 to align with the same bit in `NodeBuilderFlags`
|
||||
@@ -4728,7 +4738,7 @@ namespace ts {
|
||||
NodeBuilderFlagsMask = NoTruncation | WriteArrayAsGenericType | UseStructuralFallback | WriteTypeArgumentsOfSignature |
|
||||
UseFullyQualifiedType | SuppressAnyReturnType | MultilineObjectLiterals | WriteClassExpressionAsTypeLiteral |
|
||||
UseTypeOfFunction | OmitParameterModifiers | UseAliasDefinedOutsideCurrentScope | AllowUniqueESSymbolType | InTypeAlias |
|
||||
UseSingleQuotesForStringLiteralType | NoTypeReduction,
|
||||
UseSingleQuotesForStringLiteralType | NoTypeReduction | OmitThisParameter
|
||||
}
|
||||
|
||||
export const enum SymbolFormatFlags {
|
||||
@@ -6025,6 +6035,7 @@ namespace ts {
|
||||
export const enum TypeMapKind {
|
||||
Simple,
|
||||
Array,
|
||||
Deferred,
|
||||
Function,
|
||||
Composite,
|
||||
Merged,
|
||||
@@ -6034,7 +6045,8 @@ namespace ts {
|
||||
export type TypeMapper =
|
||||
| { kind: TypeMapKind.Simple, source: Type, target: Type }
|
||||
| { kind: TypeMapKind.Array, sources: readonly Type[], targets: readonly Type[] | undefined }
|
||||
| { kind: TypeMapKind.Function, func: (t: Type) => Type }
|
||||
| { kind: TypeMapKind.Deferred, sources: readonly Type[], targets: (() => Type)[] }
|
||||
| { kind: TypeMapKind.Function, func: (t: Type) => Type, debugInfo?: () => string }
|
||||
| { kind: TypeMapKind.Composite | TypeMapKind.Merged, mapper1: TypeMapper, mapper2: TypeMapper };
|
||||
|
||||
export const enum InferencePriority {
|
||||
@@ -6981,7 +6993,6 @@ namespace ts {
|
||||
// For testing:
|
||||
/*@internal*/ disableUseFileVersionAsSignature?: boolean;
|
||||
/*@internal*/ storeFilesChangingSignatureDuringEmit?: boolean;
|
||||
/*@internal*/ now?(): Date;
|
||||
}
|
||||
|
||||
/** true if --out otherwise source file name */
|
||||
@@ -7032,10 +7043,9 @@ namespace ts {
|
||||
ContainsPossibleTopLevelAwait = 1 << 26,
|
||||
ContainsLexicalSuper = 1 << 27,
|
||||
ContainsUpdateExpressionForIdentifier = 1 << 28,
|
||||
// Please leave this as 1 << 29.
|
||||
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
|
||||
// It is a good reminder of how much room we have left
|
||||
HasComputedFlags = 1 << 29, // Transform flags have been computed.
|
||||
ContainsPrivateIdentifierInExpression = 1 << 29,
|
||||
|
||||
HasComputedFlags = 1 << 31, // Transform flags have been computed.
|
||||
|
||||
// Assertions
|
||||
// - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
|
||||
@@ -7337,7 +7347,7 @@ namespace ts {
|
||||
parenthesizeBranchOfConditionalExpression(branch: Expression): Expression;
|
||||
parenthesizeExpressionOfExportDefault(expression: Expression): Expression;
|
||||
parenthesizeExpressionOfNew(expression: Expression): LeftHandSideExpression;
|
||||
parenthesizeLeftSideOfAccess(expression: Expression): LeftHandSideExpression;
|
||||
parenthesizeLeftSideOfAccess(expression: Expression, optionalChain?: boolean): LeftHandSideExpression;
|
||||
parenthesizeOperandOfPostfixUnary(operand: Expression): LeftHandSideExpression;
|
||||
parenthesizeOperandOfPrefixUnary(operand: Expression): UnaryExpression;
|
||||
parenthesizeExpressionsOfCommaDelimitedList(elements: readonly Expression[]): NodeArray<Expression>;
|
||||
@@ -8998,4 +9008,11 @@ namespace ts {
|
||||
negative: boolean;
|
||||
base10Value: string;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface Queue<T> {
|
||||
enqueue(...items: T[]): void;
|
||||
dequeue(): T;
|
||||
isEmpty(): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace ts {
|
||||
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
|
||||
}
|
||||
|
||||
export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): void {
|
||||
export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull | undefined, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): void {
|
||||
if (!sourceFile.resolvedModules) {
|
||||
sourceFile.resolvedModules = createModeAwareCache();
|
||||
}
|
||||
@@ -5565,7 +5565,8 @@ namespace ts {
|
||||
|
||||
export function getDeclarationModifierFlagsFromSymbol(s: Symbol, isWrite = false): ModifierFlags {
|
||||
if (s.valueDeclaration) {
|
||||
const declaration = (isWrite && s.declarations && find(s.declarations, d => d.kind === SyntaxKind.SetAccessor)) || s.valueDeclaration;
|
||||
const declaration = (isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration))
|
||||
|| (s.flags & SymbolFlags.GetAccessor && find(s.declarations, isGetAccessorDeclaration)) || s.valueDeclaration;
|
||||
const flags = getCombinedModifierFlags(declaration);
|
||||
return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier;
|
||||
}
|
||||
@@ -6319,7 +6320,7 @@ namespace ts {
|
||||
// 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 (file.impliedNodeFormat === ModuleKind.ESNext || (fileExtensionIsOneOf(file.fileName, [Extension.Cjs, Extension.Cts]))) && !file.isDeclarationFile ? true : undefined;
|
||||
return (file.impliedNodeFormat === ModuleKind.ESNext || (fileExtensionIsOneOf(file.fileName, [Extension.Cjs, Extension.Cts, Extension.Mjs, Extension.Mts]))) && !file.isDeclarationFile ? true : undefined;
|
||||
}
|
||||
|
||||
export function getSetExternalModuleIndicator(options: CompilerOptions): (file: SourceFile) => void {
|
||||
@@ -6343,10 +6344,7 @@ namespace ts {
|
||||
if (options.jsx === JsxEmit.ReactJSX || options.jsx === JsxEmit.ReactJSXDev) {
|
||||
checks.push(isFileModuleFromUsingJSXTag);
|
||||
}
|
||||
const moduleKind = getEmitModuleKind(options);
|
||||
if (moduleKind === ModuleKind.Node16 || moduleKind === ModuleKind.NodeNext) {
|
||||
checks.push(isFileForcedToBeModuleByFormat);
|
||||
}
|
||||
checks.push(isFileForcedToBeModuleByFormat);
|
||||
const combined = or(...checks);
|
||||
const callback = (file: SourceFile) => void (file.externalModuleIndicator = combined(file));
|
||||
return callback;
|
||||
|
||||
@@ -932,6 +932,12 @@ namespace ts {
|
||||
/**
|
||||
* Gets the effective type parameters. If the node was parsed in a
|
||||
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
|
||||
*
|
||||
* This does *not* return type parameters from a jsdoc reference to a generic type, eg
|
||||
*
|
||||
* type Id = <T>(x: T) => T
|
||||
* /** @type {Id} /
|
||||
* function id(x) { return x }
|
||||
*/
|
||||
export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[] {
|
||||
if (isJSDocSignature(node)) {
|
||||
|
||||
@@ -616,7 +616,7 @@ namespace ts {
|
||||
nodeVisitor(node.argument, visitor, isTypeNode),
|
||||
nodeVisitor(node.assertions, visitor, isNode),
|
||||
nodeVisitor(node.qualifier, visitor, isEntityName),
|
||||
visitNodes(node.typeArguments, visitor, isTypeNode),
|
||||
nodesVisitor(node.typeArguments, visitor, isTypeNode),
|
||||
node.isTypeOf
|
||||
);
|
||||
|
||||
@@ -630,10 +630,10 @@ namespace ts {
|
||||
case SyntaxKind.NamedTupleMember:
|
||||
Debug.type<NamedTupleMember>(node);
|
||||
return factory.updateNamedTupleMember(node,
|
||||
visitNode(node.dotDotDotToken, visitor, isDotDotDotToken),
|
||||
visitNode(node.name, visitor, isIdentifier),
|
||||
visitNode(node.questionToken, visitor, isQuestionToken),
|
||||
visitNode(node.type, visitor, isTypeNode),
|
||||
nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken),
|
||||
nodeVisitor(node.name, visitor, isIdentifier),
|
||||
nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken),
|
||||
nodeVisitor(node.type, visitor, isTypeNode),
|
||||
);
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
@@ -761,7 +761,7 @@ namespace ts {
|
||||
Debug.type<TaggedTemplateExpression>(node);
|
||||
return factory.updateTaggedTemplateExpression(node,
|
||||
nodeVisitor(node.tag, visitor, isExpression),
|
||||
visitNodes(node.typeArguments, visitor, isTypeNode),
|
||||
nodesVisitor(node.typeArguments, visitor, isTypeNode),
|
||||
nodeVisitor(node.template, visitor, isTemplateLiteral));
|
||||
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
|
||||
+39
-5
@@ -224,26 +224,59 @@ namespace ts {
|
||||
for (const file of program.getSourceFiles()) {
|
||||
write(`${toFileName(file, relativeFileName)}`);
|
||||
reasons.get(file.path)?.forEach(reason => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
|
||||
explainIfFileIsRedirect(file, relativeFileName)?.forEach(d => write(` ${d.messageText}`));
|
||||
explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)?.forEach(d => write(` ${d.messageText}`));
|
||||
}
|
||||
}
|
||||
|
||||
export function explainIfFileIsRedirect(file: SourceFile, fileNameConvertor?: (fileName: string) => string): DiagnosticMessageChain[] | undefined {
|
||||
export function explainIfFileIsRedirectAndImpliedFormat(
|
||||
file: SourceFile,
|
||||
fileNameConvertor?: (fileName: string) => string,
|
||||
): DiagnosticMessageChain[] | undefined {
|
||||
let result: DiagnosticMessageChain[] | undefined;
|
||||
if (file.path !== file.resolvedPath) {
|
||||
(result ||= []).push(chainDiagnosticMessages(
|
||||
(result ??= []).push(chainDiagnosticMessages(
|
||||
/*details*/ undefined,
|
||||
Diagnostics.File_is_output_of_project_reference_source_0,
|
||||
toFileName(file.originalFileName, fileNameConvertor)
|
||||
));
|
||||
}
|
||||
if (file.redirectInfo) {
|
||||
(result ||= []).push(chainDiagnosticMessages(
|
||||
(result ??= []).push(chainDiagnosticMessages(
|
||||
/*details*/ undefined,
|
||||
Diagnostics.File_redirects_to_file_0,
|
||||
toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)
|
||||
));
|
||||
}
|
||||
if (isExternalOrCommonJsModule(file)) {
|
||||
switch (file.impliedNodeFormat) {
|
||||
case ModuleKind.ESNext:
|
||||
if (file.packageJsonScope) {
|
||||
(result ??= []).push(chainDiagnosticMessages(
|
||||
/*details*/ undefined,
|
||||
Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module,
|
||||
toFileName(last(file.packageJsonLocations!), fileNameConvertor)
|
||||
));
|
||||
}
|
||||
break;
|
||||
case ModuleKind.CommonJS:
|
||||
if (file.packageJsonScope) {
|
||||
(result ??= []).push(chainDiagnosticMessages(
|
||||
/*details*/ undefined,
|
||||
file.packageJsonScope.packageJsonContent.type ?
|
||||
Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
|
||||
Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type,
|
||||
toFileName(last(file.packageJsonLocations!), fileNameConvertor)
|
||||
));
|
||||
}
|
||||
else if (file.packageJsonLocations?.length) {
|
||||
(result ??= []).push(chainDiagnosticMessages(
|
||||
/*details*/ undefined,
|
||||
Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found,
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -508,6 +541,7 @@ namespace ts {
|
||||
MissingFile: "Missing file",
|
||||
WildcardDirectory: "Wild card directory",
|
||||
FailedLookupLocations: "Failed Lookup Locations",
|
||||
AffectingFileLocation: "File location affecting resolution",
|
||||
TypeRoots: "Type roots",
|
||||
ConfigFileOfReferencedProject: "Config file of referened project",
|
||||
ExtendedConfigOfReferencedProject: "Extended config file of referenced project",
|
||||
@@ -529,6 +563,7 @@ namespace ts {
|
||||
MissingFile: "Missing file",
|
||||
WildcardDirectory: "Wild card directory",
|
||||
FailedLookupLocations: "Failed Lookup Locations",
|
||||
AffectingFileLocation: "File location affecting resolution",
|
||||
TypeRoots: "Type roots",
|
||||
ConfigFileOfReferencedProject: "Config file of referened project",
|
||||
ExtendedConfigOfReferencedProject: "Extended config file of referenced project",
|
||||
@@ -596,7 +631,6 @@ namespace ts {
|
||||
readDirectory: maybeBind(host, host.readDirectory),
|
||||
disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
|
||||
storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
|
||||
now: maybeBind(host, host.now),
|
||||
};
|
||||
|
||||
function writeFile(fileName: string, text: string, writeByteOrderMark: boolean, onError: (message: string) => void) {
|
||||
|
||||
+12
-10
@@ -30,7 +30,6 @@ namespace ts {
|
||||
host.createHash = maybeBind(system, system.createHash);
|
||||
host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
|
||||
host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
|
||||
host.now = maybeBind(system, system.now);
|
||||
setGetSourceFileAsHashVersioned(host, system);
|
||||
changeCompilerHostLikeToUseCache(host, fileName => toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName));
|
||||
return host;
|
||||
@@ -115,6 +114,10 @@ namespace ts {
|
||||
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
|
||||
/** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
|
||||
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
|
||||
/**
|
||||
* Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
|
||||
*/
|
||||
getModuleResolutionCache?(): ModuleResolutionCache | undefined;
|
||||
}
|
||||
/** Internal interface used to wire emit through same host */
|
||||
|
||||
@@ -284,7 +287,6 @@ namespace ts {
|
||||
let parsedConfigs: ESMap<Path, ParsedConfig> | undefined; // Parsed commandline and watching cached for referenced projects
|
||||
let sharedExtendedConfigFileWatchers: ESMap<Path, SharedExtendedConfigFileWatcher<Path>>; // Map of file watchers for extended files, shared between different referenced projects
|
||||
let extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
|
||||
let changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
|
||||
let reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
|
||||
|
||||
const sourceFilesCache = new Map<string, HostFileInfo>(); // Cache that stores the source file and version info
|
||||
@@ -342,7 +344,7 @@ namespace ts {
|
||||
compilerHost.getCompilationSettings = () => compilerOptions;
|
||||
compilerHost.useSourceOfProjectReferenceRedirect = maybeBind(host, host.useSourceOfProjectReferenceRedirect);
|
||||
compilerHost.watchDirectoryOfFailedLookupLocation = (dir, cb, flags) => watchDirectory(dir, cb, flags, watchOptions, WatchType.FailedLookupLocations);
|
||||
compilerHost.watchAffectingFileLocation = (file, cb) => watchFile(file, cb, PollingInterval.High, watchOptions, WatchType.PackageJson);
|
||||
compilerHost.watchAffectingFileLocation = (file, cb) => watchFile(file, cb, PollingInterval.High, watchOptions, WatchType.AffectingFileLocation);
|
||||
compilerHost.watchTypeRootsDirectory = (dir, cb, flags) => watchDirectory(dir, cb, flags, watchOptions, WatchType.TypeRoots);
|
||||
compilerHost.getCachedDirectoryStructureHost = () => cachedDirectoryStructureHost;
|
||||
compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
|
||||
@@ -367,6 +369,9 @@ namespace ts {
|
||||
compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
|
||||
((...args) => host.resolveTypeReferenceDirectives!(...args)) :
|
||||
((typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) => resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode));
|
||||
compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
|
||||
maybeBind(host, host.getModuleResolutionCache) :
|
||||
(() => resolutionCache.getModuleResolutionCache());
|
||||
const userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
||||
|
||||
builderProgram = readBuilderProgram(compilerOptions, compilerHost) as any as T;
|
||||
@@ -435,13 +440,13 @@ namespace ts {
|
||||
const program = getCurrentBuilderProgram();
|
||||
if (hasChangedCompilerOptions) {
|
||||
newLine = updateNewLine();
|
||||
if (program && (changesAffectResolution || changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) {
|
||||
if (program && changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
|
||||
resolutionCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// All resolutions are invalid if user provided resolutions
|
||||
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
|
||||
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
|
||||
if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
||||
if (hasChangedConfigFileParsingErrors) {
|
||||
if (reportFileChangeDetectedOnCreateProgram) {
|
||||
@@ -458,7 +463,6 @@ namespace ts {
|
||||
createNewProgram(hasInvalidatedResolution);
|
||||
}
|
||||
|
||||
changesAffectResolution = false; // reset for next sync
|
||||
reportFileChangeDetectedOnCreateProgram = false;
|
||||
|
||||
if (host.afterProgramCreate && program !== builderProgram) {
|
||||
@@ -481,8 +485,9 @@ namespace ts {
|
||||
resolutionCache.startCachingPerDirectoryResolution();
|
||||
compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
|
||||
compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
|
||||
const oldProgram = getCurrentProgram();
|
||||
builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
|
||||
resolutionCache.finishCachingPerDirectoryResolution();
|
||||
resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
|
||||
|
||||
// Update watches
|
||||
updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new Map()), watchMissingFilePath);
|
||||
@@ -574,9 +579,6 @@ namespace ts {
|
||||
sourceFilesCache.set(path, false);
|
||||
}
|
||||
}
|
||||
if (sourceFile) {
|
||||
sourceFile.impliedNodeFormat = getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
|
||||
}
|
||||
return sourceFile;
|
||||
}
|
||||
return hostSourceFile.sourceFile;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace ts.server {
|
||||
export class SessionClient implements LanguageService {
|
||||
private sequence = 0;
|
||||
private lineMaps = new Map<string, number[]>();
|
||||
private messages: string[] = [];
|
||||
private messages = createQueue<string>();
|
||||
private lastRenameEntry: RenameEntry | undefined;
|
||||
private preferences: UserPreferences | undefined;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
public onMessage(message: string): void {
|
||||
this.messages.push(message);
|
||||
this.messages.enqueue(message);
|
||||
}
|
||||
|
||||
private writeMessage(message: string): void {
|
||||
@@ -95,7 +95,7 @@ namespace ts.server {
|
||||
let foundResponseMessage = false;
|
||||
let response!: T;
|
||||
while (!foundResponseMessage) {
|
||||
const lastMessage = this.messages.shift()!;
|
||||
const lastMessage = this.messages.dequeue()!;
|
||||
Debug.assert(!!lastMessage, "Did not receive any responses.");
|
||||
const responseBody = extractMessage(lastMessage);
|
||||
try {
|
||||
@@ -876,6 +876,10 @@ namespace ts.server {
|
||||
throw new Error("Program objects are not serializable through the server protocol.");
|
||||
}
|
||||
|
||||
getCurrentProgram(): Program | undefined {
|
||||
throw new Error("Program objects are not serializable through the server protocol.");
|
||||
}
|
||||
|
||||
getAutoImportProvider(): Program | undefined {
|
||||
throw new Error("Program objects are not serializable through the server protocol.");
|
||||
}
|
||||
|
||||
@@ -2256,7 +2256,7 @@ namespace FourSlash {
|
||||
this.languageServiceAdapterHost,
|
||||
this.languageService.getProgram()?.getCompilerOptions() || {}
|
||||
),
|
||||
setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.languageService.getProgram()?.getCompilerOptions() || {})
|
||||
setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.languageService.getProgram()?.getCompilerOptions() || {}),
|
||||
};
|
||||
const referenceSourceFile = ts.createLanguageServiceSourceFile(
|
||||
this.activeFile.fileName, createScriptSnapShot(content), options, /*version:*/ "0", /*setNodeParents:*/ false);
|
||||
|
||||
@@ -627,6 +627,9 @@ namespace Harness.LanguageService {
|
||||
getProgram(): ts.Program {
|
||||
throw new Error("Program can not be marshaled across the shim layer.");
|
||||
}
|
||||
getCurrentProgram(): ts.Program | undefined {
|
||||
throw new Error("Program can not be marshaled across the shim layer.");
|
||||
}
|
||||
getAutoImportProvider(): ts.Program | undefined {
|
||||
throw new Error("Program can not be marshaled across the shim layer.");
|
||||
}
|
||||
|
||||
@@ -116,7 +116,14 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
|
||||
function createWatcher<T>(map: MultiMap<Path, T>, path: Path, callback: T): FileWatcher {
|
||||
map.add(path, callback);
|
||||
return { close: () => map.remove(path, callback) };
|
||||
let closed = false;
|
||||
return {
|
||||
close: () => {
|
||||
Debug.assert(!closed);
|
||||
map.remove(path, callback);
|
||||
closed = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function getDiffInKeys<T>(map: ESMap<string, T>, expectedKeys: readonly string[]) {
|
||||
|
||||
Vendored
+2
-2
@@ -13828,11 +13828,11 @@ declare var SubmitEvent: {
|
||||
* Available only in secure contexts.
|
||||
*/
|
||||
interface SubtleCrypto {
|
||||
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
|
||||
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
||||
deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
|
||||
deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
|
||||
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
|
||||
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
|
||||
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
||||
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
|
||||
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
|
||||
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
|
||||
|
||||
Vendored
+62
-1
@@ -1,16 +1,36 @@
|
||||
interface Map<K, V> {
|
||||
|
||||
clear(): void;
|
||||
/**
|
||||
* @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
|
||||
*/
|
||||
delete(key: K): boolean;
|
||||
/**
|
||||
* Executes a provided function once per each key/value pair in the Map, in insertion order.
|
||||
*/
|
||||
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
|
||||
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
||||
*/
|
||||
get(key: K): V | undefined;
|
||||
/**
|
||||
* @returns boolean indicating whether an element with the specified key exists or not.
|
||||
*/
|
||||
has(key: K): boolean;
|
||||
/**
|
||||
* Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
|
||||
*/
|
||||
set(key: K, value: V): this;
|
||||
/**
|
||||
* @returns the number of elements in the Map.
|
||||
*/
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new(): Map<any, any>;
|
||||
new<K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
|
||||
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
|
||||
readonly prototype: Map<any, any>;
|
||||
}
|
||||
declare var Map: MapConstructor;
|
||||
@@ -23,9 +43,23 @@ interface ReadonlyMap<K, V> {
|
||||
}
|
||||
|
||||
interface WeakMap<K extends object, V> {
|
||||
/**
|
||||
* Removes the specified element from the WeakMap.
|
||||
* @returns true if the element was successfully removed, or false if it was not present.
|
||||
*/
|
||||
delete(key: K): boolean;
|
||||
/**
|
||||
* @returns a specified element.
|
||||
*/
|
||||
get(key: K): V | undefined;
|
||||
/**
|
||||
* @returns a boolean indicating whether an element with the specified key exists or not.
|
||||
*/
|
||||
has(key: K): boolean;
|
||||
/**
|
||||
* Adds a new element with a specified key and value.
|
||||
* @param key Must be an object.
|
||||
*/
|
||||
set(key: K, value: V): this;
|
||||
}
|
||||
|
||||
@@ -36,11 +70,28 @@ interface WeakMapConstructor {
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
interface Set<T> {
|
||||
/**
|
||||
* Appends a new element with a specified value to the end of the Set.
|
||||
*/
|
||||
add(value: T): this;
|
||||
|
||||
clear(): void;
|
||||
/**
|
||||
* Removes a specified value from the Set.
|
||||
* @returns Returns true if an element in the Set existed and has been removed, or false if the element does not exist.
|
||||
*/
|
||||
delete(value: T): boolean;
|
||||
/**
|
||||
* Executes a provided function once per each value in the Set object, in insertion order.
|
||||
*/
|
||||
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
/**
|
||||
* @returns a boolean indicating whether an element with the specified value exists in the Set or not.
|
||||
*/
|
||||
has(value: T): boolean;
|
||||
/**
|
||||
* @returns the number of (unique) elements in Set.
|
||||
*/
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
@@ -57,8 +108,18 @@ interface ReadonlySet<T> {
|
||||
}
|
||||
|
||||
interface WeakSet<T extends object> {
|
||||
/**
|
||||
* Appends a new object to the end of the WeakSet.
|
||||
*/
|
||||
add(value: T): this;
|
||||
/**
|
||||
* Removes the specified element from the WeakSet.
|
||||
* @returns Returns true if the element existed and has been removed, or false if the element does not exist.
|
||||
*/
|
||||
delete(value: T): boolean;
|
||||
/**
|
||||
* @returns a boolean indicating whether an object exists in the WeakSet or not.
|
||||
*/
|
||||
has(value: T): boolean;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+9
-4
@@ -21,7 +21,7 @@ interface PromiseConstructor {
|
||||
all<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]> }>;
|
||||
|
||||
// see: lib.es2015.iterable.d.ts
|
||||
// all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>;
|
||||
// all<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
@@ -32,7 +32,7 @@ interface PromiseConstructor {
|
||||
race<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
|
||||
|
||||
// see: lib.es2015.iterable.d.ts
|
||||
// race<T>(values: Iterable<T>): Promise<T extends PromiseLike<infer U> ? U : T>;
|
||||
// race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
@@ -46,13 +46,18 @@ interface PromiseConstructor {
|
||||
* @returns A resolved promise.
|
||||
*/
|
||||
resolve(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
|
||||
resolve<T>(value: T): Promise<Awaited<T>>;
|
||||
/**
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
resolve<T>(value: T | PromiseLike<T>): Promise<Awaited<T>>;
|
||||
}
|
||||
|
||||
declare var Promise: PromiseConstructor;
|
||||
|
||||
Vendored
+91
-2
@@ -1,21 +1,110 @@
|
||||
interface ProxyHandler<T extends object> {
|
||||
/**
|
||||
* A trap method for a function call.
|
||||
* @param target The original callable object which is being proxied.
|
||||
*/
|
||||
apply?(target: T, thisArg: any, argArray: any[]): any;
|
||||
|
||||
/**
|
||||
* A trap for the `new` operator.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param newTarget The constructor that was originally called.
|
||||
*/
|
||||
construct?(target: T, argArray: any[], newTarget: Function): object;
|
||||
defineProperty?(target: T, p: string | symbol, attributes: PropertyDescriptor): boolean;
|
||||
|
||||
/**
|
||||
* A trap for `Object.defineProperty()`.
|
||||
* @param target The original object which is being proxied.
|
||||
* @returns A `Boolean` indicating whether or not the property has been defined.
|
||||
*/
|
||||
defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean;
|
||||
|
||||
/**
|
||||
* A trap for the `delete` operator.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name or `Symbol` of the property to delete.
|
||||
* @returns A `Boolean` indicating whether or not the property was deleted.
|
||||
*/
|
||||
deleteProperty?(target: T, p: string | symbol): boolean;
|
||||
|
||||
/**
|
||||
* A trap for getting a property value.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name or `Symbol` of the property to get.
|
||||
* @param receiver The proxy or an object that inherits from the proxy.
|
||||
*/
|
||||
get?(target: T, p: string | symbol, receiver: any): any;
|
||||
|
||||
/**
|
||||
* A trap for `Object.getOwnPropertyDescriptor()`.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name of the property whose description should be retrieved.
|
||||
*/
|
||||
getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined;
|
||||
|
||||
/**
|
||||
* A trap for the `[[GetPrototypeOf]]` internal method.
|
||||
* @param target The original object which is being proxied.
|
||||
*/
|
||||
getPrototypeOf?(target: T): object | null;
|
||||
|
||||
/**
|
||||
* A trap for the `in` operator.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name or `Symbol` of the property to check for existence.
|
||||
*/
|
||||
has?(target: T, p: string | symbol): boolean;
|
||||
|
||||
/**
|
||||
* A trap for `Object.isExtensible()`.
|
||||
* @param target The original object which is being proxied.
|
||||
*/
|
||||
isExtensible?(target: T): boolean;
|
||||
|
||||
/**
|
||||
* A trap for `Reflect.ownKeys()`.
|
||||
* @param target The original object which is being proxied.
|
||||
*/
|
||||
ownKeys?(target: T): ArrayLike<string | symbol>;
|
||||
|
||||
/**
|
||||
* A trap for `Object.preventExtensions()`.
|
||||
* @param target The original object which is being proxied.
|
||||
*/
|
||||
preventExtensions?(target: T): boolean;
|
||||
set?(target: T, p: string | symbol, value: any, receiver: any): boolean;
|
||||
|
||||
/**
|
||||
* A trap for setting a property value.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name or `Symbol` of the property to set.
|
||||
* @param receiver The object to which the assignment was originally directed.
|
||||
* @returns `A `Boolean` indicating whether or not the property was set.
|
||||
*/
|
||||
set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean;
|
||||
|
||||
/**
|
||||
* A trap for `Object.setPrototypeOf()`.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param newPrototype The object's new prototype or `null`.
|
||||
*/
|
||||
setPrototypeOf?(target: T, v: object | null): boolean;
|
||||
}
|
||||
|
||||
interface ProxyConstructor {
|
||||
/**
|
||||
* Creates a revocable Proxy object.
|
||||
* @param target A target object to wrap with Proxy.
|
||||
* @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
|
||||
*/
|
||||
revocable<T extends object>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
|
||||
|
||||
/**
|
||||
* Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the
|
||||
* original object, but which may redefine fundamental Object operations like getting, setting, and defining
|
||||
* properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.
|
||||
* @param target A target object to wrap with Proxy.
|
||||
* @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
|
||||
*/
|
||||
new <T extends object>(target: T, handler: ProxyHandler<T>): T;
|
||||
}
|
||||
declare var Proxy: ProxyConstructor;
|
||||
|
||||
Vendored
+16
-1
@@ -1,5 +1,20 @@
|
||||
declare namespace Intl {
|
||||
type DateTimeFormatPartTypes = "day" | "dayPeriod" | "era" | "hour" | "literal" | "minute" | "month" | "second" | "timeZoneName" | "weekday" | "year";
|
||||
|
||||
interface DateTimeFormatPartTypesRegistry {
|
||||
day: any
|
||||
dayPeriod: any
|
||||
era: any
|
||||
hour: any
|
||||
literal: any
|
||||
minute: any
|
||||
month: any
|
||||
second: any
|
||||
timeZoneName: any
|
||||
weekday: any
|
||||
year: any
|
||||
}
|
||||
|
||||
type DateTimeFormatPartTypes = keyof DateTimeFormatPartTypesRegistry;
|
||||
|
||||
interface DateTimeFormatPart {
|
||||
type: DateTimeFormatPartTypes;
|
||||
|
||||
Vendored
+4
@@ -1,5 +1,9 @@
|
||||
declare namespace Intl {
|
||||
|
||||
interface DateTimeFormatPartTypesRegistry {
|
||||
fractionalSecond: any
|
||||
}
|
||||
|
||||
interface DateTimeFormatOptions {
|
||||
formatMatcher?: "basic" | "best fit" | "best fit" | undefined;
|
||||
dateStyle?: "full" | "long" | "medium" | "short" | undefined;
|
||||
|
||||
Vendored
+2
-2
@@ -1,9 +1,9 @@
|
||||
interface ErrorOptions {
|
||||
cause?: Error;
|
||||
cause?: unknown;
|
||||
}
|
||||
|
||||
interface Error {
|
||||
cause?: Error;
|
||||
cause?: unknown;
|
||||
}
|
||||
|
||||
interface ErrorConstructor {
|
||||
|
||||
Vendored
+14
-2
@@ -913,12 +913,24 @@ interface DateConstructor {
|
||||
declare var Date: DateConstructor;
|
||||
|
||||
interface RegExpMatchArray extends Array<string> {
|
||||
/**
|
||||
* The index of the search at which the result was found.
|
||||
*/
|
||||
index?: number;
|
||||
/**
|
||||
* A copy of the search string.
|
||||
*/
|
||||
input?: string;
|
||||
}
|
||||
|
||||
interface RegExpExecArray extends Array<string> {
|
||||
/**
|
||||
* The index of the search at which the result was found.
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* A copy of the search string.
|
||||
*/
|
||||
input: string;
|
||||
}
|
||||
|
||||
@@ -1500,8 +1512,8 @@ interface Promise<T> {
|
||||
*/
|
||||
type Awaited<T> =
|
||||
T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
|
||||
T extends object & { then(onfulfilled: infer F): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
|
||||
F extends ((value: infer V, ...args: any) => any) ? // if the argument to `then` is callable, extracts the first argument
|
||||
T extends object & { then(onfulfilled: infer F, ...args: infer _): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
|
||||
F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first argument
|
||||
Awaited<V> : // recursively unwrap the value
|
||||
never : // the argument to `then` was not callable
|
||||
T; // non-object or non-thenable
|
||||
|
||||
Vendored
+2
-2
@@ -2988,11 +2988,11 @@ declare var StorageManager: {
|
||||
* Available only in secure contexts.
|
||||
*/
|
||||
interface SubtleCrypto {
|
||||
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
|
||||
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
||||
deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
|
||||
deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
|
||||
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
|
||||
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
|
||||
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
||||
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
|
||||
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
|
||||
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
|
||||
|
||||
@@ -900,6 +900,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[不能使用负值为元组类型编制索引。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -2112,6 +2121,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[实例化表达式不能后跟属性访问。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6516,6 +6534,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[文件是 CommonJS 模块,因为“{0}”没有字段 “type”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[文件是 CommonJS 模块,因为“{0}”具有值不是 “module” 的字段 “type”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[文件是 CommonJS 模块,因为找不到 “package.json”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[文件是 ECMAScript 模块,因为“{0}”具有值为 “module” 的字段 “type”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7194,6 +7248,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[应为标识符或字符串字面量。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -14451,6 +14514,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[实例成员变量“{0}”的类型不能引用构造函数中声明的标识符“{1}”。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14697,6 +14769,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[类型不能出现在 JavaScript 文件的导出声明中。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15393,6 +15474,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[不能重命名已在 “node_modules” 文件夹中定义的元素。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[不能重命名已在另一个 “node_modules” 文件夹中定义的元素。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15636,6 +15735,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[“{0}”是一种类型,无法在 JavaScript 文件中导入。请在 JSDoc 类型批注中使用“{1}”。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15663,6 +15771,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[“{0}”自动导出到此处。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -900,6 +900,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[元組類型無法以負值編製索引。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -2112,6 +2121,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[具現化運算式後面不能接著屬性存取。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6516,6 +6534,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[檔案是 CommonJS 模組,因為 '{0}' 沒有 "type" 欄位]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[檔案是 CommonJS 模組,因為 '{0}' 具有值不是 "module" 的 "type" 欄位]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[檔案是 CommonJS 模組,因為找不到 'package.json']]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[檔案是 ECMAScript 模組,因為 '{0}' 具有值不是 "module" 的 "type" 欄位]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7194,6 +7248,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[需要識別碼或字串常值。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -14451,6 +14514,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[執行個體成員變數 '{0}' 的類型不得參考建構函式中所宣告的識別碼 '{1}'。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14697,6 +14769,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[類型不能出現在 JavaScript 檔案的匯出宣告中。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15393,6 +15474,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[您無法重新命名 'node_modules' 資料夾中定義的元素。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[您無法重新命名其他 'node_modules' 資料夾中定義的元素。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15636,6 +15735,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' 為類型,無法匯入 JavaScript 檔案。在 JSDoc 類型註釋中使用 '{1}'。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15663,6 +15771,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' 會自動匯出到此處。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -909,6 +909,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Typ řazené kolekce členů není možné indexovat zápornou hodnotou.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -1254,12 +1263,18 @@
|
||||
<Item ItemId=";Add_extends_constraint_2211" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Přidejte omezení extends.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_to_all_type_parameters_2212" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint to all type parameters]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Přidat omezení extends ke všem parametrům typu]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
@@ -2115,6 +2130,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Po výrazu vytvoření instance nemůže následovat přístup k vlastnosti.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6519,6 +6543,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Soubor je modul CommonJS, protože {0} nemá pole type]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Soubor je modul CommonJS, protože {0} má pole type, jehož hodnota není module]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Soubor je modul CommonJS, protože se nenašel package.json]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Soubor je modul ECMAScript, protože {0} má pole type s hodnotou module]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7197,6 +7257,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Očekává se identifikátor nebo řetězcový literál.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -13854,6 +13923,9 @@
|
||||
<Item ItemId=";This_type_parameter_might_need_an_extends_0_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[This type parameter might need an `extends {0}` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Tento parametr typu může potřebovat omezení extends {0}.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
@@ -14451,6 +14523,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Typ instance členské proměnné {0} nemůže odkazovat na identifikátor {1} deklarovaný v konstruktoru.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14697,6 +14778,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Typy se v deklaracích exportu v souborech JavaScriptu nemůžou vyskytovat.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15393,6 +15483,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Nelze přejmenovat elementy definované ve složce node_modules.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Nelze přejmenovat elementy definované v jiné složce node_modules.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15636,6 +15744,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[{0} je typ a nedá se importovat do javascriptových souborů. V poznámce typu JSDoc použijte {1}.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15663,6 +15780,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[{0} se sem automaticky exportuje.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -897,6 +897,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Ein Tupeltyp kann nicht mit einem negativen Wert indiziert werden.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -1239,6 +1248,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_2211" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA["extends"-Einschränkung hinzufügen]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_to_all_type_parameters_2212" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint to all type parameters]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA["extends"-Einschränkung zu allen Typparametern hinzufügen]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_import_from_0_90057" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add import from "{0}"]]></Val>
|
||||
@@ -2091,6 +2118,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Auf einen Instanziierungsausdruck kann kein Eigenschaftenzugriff folgen.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6495,6 +6531,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Die Datei ist ein CommonJS-Modul, da '{0}' nicht das Feld „Typ“ aufweist]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Die Datei ist ein CommonJS-Modul, da '{0}' das Feld „Typ“ aufweist, dessen Wert nicht „Modul“ ist]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Die Datei ist ein CommonJS-Modul, da „package.json“ nicht gefunden wurde]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Die Datei ist ein ECMAScript-Modul, da '{0}' das Feld „Typ“ mit dem Wert „Modul“ aufweist.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7173,6 +7245,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Bezeichner oder Zeichenfolgenliteral erwartet.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -13824,11 +13905,11 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";This_type_parameter_probably_needs_an_extends_object_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Item ItemId=";This_type_parameter_might_need_an_extends_0_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[This type parameter probably needs an `extends object` constraint.]]></Val>
|
||||
<Val><![CDATA[This type parameter might need an `extends {0}` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Dieser Typparameter benötigt wahrscheinlich eine „extends object“-Einschränkung.]]></Val>
|
||||
<Val><![CDATA[Für diesen Typparameter ist möglicherweise die Einschränkung "extends {0}" erforderlich.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -14427,6 +14508,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Der Typ der Instanzmembervariablen „{0}“ darf nicht auf den im Konstruktor deklarierten Bezeichner „{1}“ verweisen.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14673,6 +14763,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Typen können in Exportdeklarationen in JavaScript-Dateien nicht angezeigt werden.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15369,6 +15468,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Elemente, die in einem Ordner "node_modules" definiert sind, können nicht umbenannt werden.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Elemente, die in einem anderen Ordner "node_modules" definiert sind, können nicht umbenannt werden.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15612,6 +15729,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA["{0}" ist ein Typ und kann nicht in JavaScript-Dateien importiert werden. Verwenden Sie "{1}" in einer JSDoc-Typanmerkung.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15639,6 +15765,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA["{0}" wird hier automatisch exportiert.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -909,6 +909,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Un tipo de tupla no se puede indizar con un valor negativo.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -2124,6 +2133,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Una expresión de creación de una instancia no puede ir seguida de un acceso a una propiedad.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6528,6 +6546,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[El archivo es un módulo CommonJS porque “{0}” no tiene el campo “type”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[El archivo es el módulo CommonJS porque “{0}” tiene el campo “type” cuyo valor no es “module”.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[El archivo es un módulo CommonJS porque no se encontró “package.json”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[El archivo es un módulo ECMAScript porque “{0}” tiene el campo “type” con el valor “module”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7206,6 +7260,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Se esperaba un literal de cadena o identificador]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -14463,6 +14526,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[El tipo de variable miembro de instancia "{0}" no puede hacer referencia al identificador "{1}" declarado en el constructor.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14709,6 +14781,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Los tipos no pueden aparecer en declaraciones de exportación en archivos JavaScript.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15405,6 +15486,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[No se puede cambiar el nombre de los elementos definidos en una carpeta 'node_modules'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[No se puede cambiar el nombre de los elementos definidos en otra carpeta 'node_modules'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15648,6 +15747,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' es un tipo y no se puede importar en archivos JavaScript. Use '{1}' en una anotación de tipo JSDoc.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15675,6 +15783,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' se exporta automáticamente aquí.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -909,6 +909,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Un type tuple ne peut pas être indexé avec une valeur négative.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -2124,6 +2133,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Une expression d’instanciation ne peut pas être suivie d’un accès à la propriété.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6528,6 +6546,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Le fichier est un module CommonJS, car « {0} » n’a pas de champ « type »]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Le fichier est un module CommonJS, car « {0} » a un champ « type » dont la valeur n’est pas « module »]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Le fichier est un module CommonJS, car « package.json » est introuvable]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Le fichier est un module ECMAScript, car « {0} » a un champ « type » avec la valeur « module »]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7206,6 +7260,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Identificateur ou littéral de chaîne attendu]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -14463,6 +14526,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Le type de variable membre d’instance '{0}' ne peut pas référencer l’identificateur '{1}' déclaré dans le constructeur.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14709,6 +14781,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Les types ne peuvent pas apparaître dans les déclarations d’exportation dans les fichiers JavaScript.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15405,6 +15486,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Vous ne pouvez pas renommer les éléments définis dans un dossier « node_modules ».]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Vous ne pouvez pas renommer les éléments définis dans un autre dossier « node_modules ».]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15648,6 +15747,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' est un type qui ne peut pas être importé dans des fichiers JavaScript. Utilisez '{1}' dans une annotation de type JSDoc.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15675,6 +15783,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' est automatiquement exporté ici.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -900,6 +900,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Un tipo di tupla non può essere indicizzato con un valore negativo.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -1242,6 +1251,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_2211" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Aggiungere il vincolo 'extends'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_to_all_type_parameters_2212" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint to all type parameters]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Aggiungere il vincolo `extends` a tutti i parametri di tipo]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_import_from_0_90057" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add import from "{0}"]]></Val>
|
||||
@@ -2094,6 +2121,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Un'espressione di creazione di un'istanza non può essere seguita da un accesso a proprietà.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6498,6 +6534,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Il file è un modulo CommonJS perché '{0}' non contiene il campo "type"]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Il file è un modulo CommonJS perché '{0}' contiene il campo "type" il cui valore non è "module"]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Il file è un modulo CommonJS perché 'package.json' non è stato trovato]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Il file è un modulo ECMAScript perché '{0}' contiene il campo "type" con valore "module"]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7176,6 +7248,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Previsto identificatore o valore letterale stringa.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -13830,11 +13911,11 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";This_type_parameter_probably_needs_an_extends_object_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Item ItemId=";This_type_parameter_might_need_an_extends_0_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[This type parameter probably needs an `extends object` constraint.]]></Val>
|
||||
<Val><![CDATA[This type parameter might need an `extends {0}` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Questo parametro di tipo richiede probabilmente un vincolo 'extends object'.]]></Val>
|
||||
<Val><![CDATA[Questo parametro di tipo potrebbe richiedere un vincolo `extends {0}`.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -14433,6 +14514,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Il tipo di variabile del membro di istanza '{0}' non può fare riferimento all'identificatore '{1}' dichiarato nel costruttore.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14679,6 +14769,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[I tipi non possono essere visualizzati nelle dichiarazioni di esportazione nei file JavaScript.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15375,6 +15474,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Non è possibile rinominare gli elementi definiti in una cartella 'node_modules'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Non è possibile rinominare gli elementi definiti in un'altra cartella 'node_modules'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15618,6 +15735,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' è un tipo e non può essere importato nei file JavaScript. Usare '{1}' in un'annotazione di tipo JSDoc.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15645,6 +15771,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' viene esportato automaticamente qui.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -900,6 +900,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[タプル型に負の値のインデックスを指定することはできません。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -1242,6 +1251,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_2211" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['extends' 制約を追加します。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_to_all_type_parameters_2212" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint to all type parameters]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[すべての型パラメーターに 'extends' 制約を追加する]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_import_from_0_90057" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add import from "{0}"]]></Val>
|
||||
@@ -2094,6 +2121,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[インスタンス化式の後にプロパティ アクセスを続けることはできません。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6498,6 +6534,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' にはフィールド "type" がないため、ファイルは CommonJS モジュールです]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' にフィールド "type" があり、値が "module" ではないため、ファイルは CommonJS モジュールです。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA["package.json" が見つからなかったため、ファイルは CommonJS モジュールです]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' には値 "module" のフィールド "type" があるため、ファイルは ECMAScript モジュールです。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7176,6 +7248,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[識別子または文字列リテラルが必要です。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -13830,11 +13911,11 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";This_type_parameter_probably_needs_an_extends_object_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Item ItemId=";This_type_parameter_might_need_an_extends_0_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[This type parameter probably needs an `extends object` constraint.]]></Val>
|
||||
<Val><![CDATA[This type parameter might need an `extends {0}` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[この型パラメーターには、`extends object` 制約が必要な可能性があります。]]></Val>
|
||||
<Val><![CDATA[この型パラメーターには 'extends {0}' 制約が必要な場合があります。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -14433,6 +14514,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[インスタンス メンバー変数 '{0}' の型は、コンストラクターで宣言された識別子 '{1}' を参照できません。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14679,6 +14769,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[JavaScript ファイルのエクスポート宣言に型を含めることはできません。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15375,6 +15474,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['node_modules' フォルダーで定義されている要素の名前を変更することはできません。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[別の 'node_modules' フォルダーで定義されている要素の名前を変更することはできません。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15618,6 +15735,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' は型であるため、JavaScript ファイルにインポートできません。JSDoc 型の注釈で '{1}' を使用します。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15645,6 +15771,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[`{0}` は自動的にここにエクスポートされます。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -900,6 +900,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[튜플 형식은 음수 값으로 인덱싱할 수 없습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -2112,6 +2121,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[인스턴스화 식 뒤에 속성 액세스가 있을 수 없습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6516,6 +6534,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}'에 "type" 필드가 없으므로 파일이 CommonJS 모듈입니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}'에 값이 "module"이 아닌 "type" 필드가 있으므로 파일이 CommonJS 모듈입니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['package.json'을 찾을 수 없으므로 파일이 CommonJS 모듈입니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}'에 값이 "module"인 "type" 필드가 있으므로 파일이 ECMAScript 모듈입니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7194,6 +7248,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[식별자 또는 문자열 리터럴이 필요합니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -14451,6 +14514,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[인스턴스 멤버 변수 '{0}'의 형식은 생성자에 선언된 식별자 '{1}'을(를) 참조할 수 없습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14697,6 +14769,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[유형은 JavaScript 파일의 내보내기 선언에 나타날 수 없습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15393,6 +15474,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['node_modules' 폴더에 정의된 요소의 이름은 변경할 수 없습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[다른 'node_modules' 폴더에 정의된 요소의 이름은 변경할 수 없습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15636,6 +15735,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}'은(는) 유형이며 JavaScript 파일로 가져올 수 없습니다. JSDoc 유형 주석에서 '{1}'을(를) 사용하세요.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15663,6 +15771,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}'은(는) 여기에서 자동으로 내보내집니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -890,6 +890,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Nie można indeksować typu krotki z wartością ujemną.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -1235,12 +1244,18 @@
|
||||
<Item ItemId=";Add_extends_constraint_2211" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Dodaj ograniczenie „rozszerzeń”.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_to_all_type_parameters_2212" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint to all type parameters]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Dodaj ograniczenie „rozszerzeń” do wszystkich parametrów typu]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
@@ -2096,6 +2111,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Po wyrażeniu tworzenia wystąpienia nie może następować dostęp do właściwości.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6500,6 +6524,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Plik jest modułem CommonJS, ponieważ element „{0}” nie ma pola „type”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Plik jest modułem CommonJS, ponieważ element „{0}” ma pole „type”, którego wartość nie jest „module”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Plik jest modułem CommonJS, ponieważ nie znaleziono pliku „package.json”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Plik jest modułem ECMAScript, ponieważ element „{0}” ma pole „type” z wartością „module”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7178,6 +7238,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Oczekiwano identyfikatora lub literału ciągu.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -13832,6 +13901,9 @@
|
||||
<Item ItemId=";This_type_parameter_might_need_an_extends_0_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[This type parameter might need an `extends {0}` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Ten parametr typu może wymagać ograniczenia „rozszerzeń{0}”.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
@@ -14429,6 +14501,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Typ zmiennej składowej wystąpienia „{0}” nie może odwoływać się do identyfikatora „{1}” zadeklarowanego w konstruktorze.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14675,6 +14756,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Typy nie mogą występować w deklaracjach eksportu w plikach JavaScript.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15371,6 +15461,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Nie można zmieniać nazw elementów zdefiniowanych w folderze „node_modules”.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Nie można zmieniać nazw elementów zdefiniowanych w innym folderze „node_modules”.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15614,6 +15722,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[„{0}” jest typem i nie można go zaimportować w plikach JavaScript. Użyj elementu „{1}” w adnotacji typu JSDoc.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15641,6 +15758,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[W tym miejscu jest automatycznie eksportowany element „{0}”.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -890,6 +890,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Um tipo de tupla não pode ser indexado com um valor negativo.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -2105,6 +2114,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Uma expressão de instanciação não pode ser seguida por um acesso de propriedade.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6509,6 +6527,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[O arquivo é um módulo CommonJS porque '{0}' não tem o campo "type"]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[O arquivo é o módulo CommonJS porque '{0}' tem o campo "type" cujo valor não é "module"]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[O arquivo é um módulo CommonJS porque 'package.json' não foi encontrado]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[O arquivo é o módulo ECMAScript porque '{0}' tem o campo "type" com o valor "module"]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7187,6 +7241,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Identificador ou literal de cadeia de caracteres esperado.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -14441,6 +14504,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[O tipo de variável '{0}' de membro de instância não pode referenciar o identificador '{1}' declarado no construtor.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14687,6 +14759,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Os tipos não podem aparecer em declarações de exportação em arquivos JavaScript.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15383,6 +15464,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Não é possível renomear elementos definidos em uma pasta 'node_modules'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Não é possível renomear elementos definidos em outra pasta 'node_modules'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15626,6 +15725,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' é um tipo e não pode ser importado em arquivos JavaScript. Use '{1}' em uma anotação de tipo JSDoc.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15653,6 +15761,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' é exportado automaticamente aqui.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -899,6 +899,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Тип кортежа нельзя индексировать с отрицательным значением.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -2111,6 +2120,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[За выражением создания экземпляра не может следовать доступ к свойству.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6515,6 +6533,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Файл является модулем CommonJS, так как "{0}" не содержит поле "type"]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Файл является модулем CommonJS, так как "{0}" содержит поле "type", значение которого отличается от "module"]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Файл является модулем CommonJS, так как "package.json" не найден]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Файл является модулем ECMAScript, так как "{0}" содержит поле "type" со значением "module"]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7193,6 +7247,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Ожидался идентификатор или строковый литерал.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -14450,6 +14513,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Инициализатор переменной-элемента экземпляра "{0}" не может ссылаться на идентификатор "{1}", объявленный в конструкторе.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14696,6 +14768,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Типы не могут отображаться в объявлениях экспорта в файлах JavaScript.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15392,6 +15473,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Невозможно переименовать элементы, определенные в папке "node_modules".]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Невозможно переименовать элементы, определенные в другой папке "node_modules".]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15635,6 +15734,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA["{0}" является типом и не может импортироваться в файлы JavaScript. Используйте "{1}" в заметке типа JSDoc.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15662,6 +15770,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA["{0}" экспортирован автоматически.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -893,6 +893,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_tuple_type_cannot_be_indexed_with_a_negative_value_2514" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A tuple type cannot be indexed with a negative value.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Bir demet türünün negatif bir değerle dizini oluşturulamaz.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
|
||||
@@ -1235,6 +1244,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_2211" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[`extends` kısıtlaması ekleyin.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_extends_constraint_to_all_type_parameters_2212" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add `extends` constraint to all type parameters]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Tüm tür parametrelerine `extends` kısıtlaması ekleyin]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Add_import_from_0_90057" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add import from "{0}"]]></Val>
|
||||
@@ -2087,6 +2114,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_instantiation_expression_cannot_be_followed_by_a_property_access_1477" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An instantiation expression cannot be followed by a property access.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Bir örnek oluşturma ifadesinin ardından özellik erişimi gelemez.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[An interface can only extend an identifier/qualified-name with optional type arguments.]]></Val>
|
||||
@@ -6491,6 +6527,42 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_does_not_have_field_type_1460" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' does not have field "type"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}', "type" alanına sahip olmadığından dosya CommonJS modülüdür]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because '{0}' has field "type" whose value is not "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}', değeri "module" olmayan "type" alanına sahip olduğundan dosya CommonJS modülüdür]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_CommonJS_module_because_package_json_was_not_found_1461" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is CommonJS module because 'package.json' was not found]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['package.json' bulunamadığından dosya CommonJS modülüdür]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is ECMAScript module because '{0}' has field "type" with value "module"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}', değeri "module" olan "type" alanına sahip olduğundan dosya ECMAScript modülüdür]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
|
||||
@@ -7169,6 +7241,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Identifier_or_string_literal_expected_1478" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Identifier or string literal expected.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Tanımlayıcı veya sabit değerli dize bekleniyor.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}']]></Val>
|
||||
@@ -13823,11 +13904,11 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";This_type_parameter_probably_needs_an_extends_object_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Item ItemId=";This_type_parameter_might_need_an_extends_0_constraint_2208" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[This type parameter probably needs an `extends object` constraint.]]></Val>
|
||||
<Val><![CDATA[This type parameter might need an `extends {0}` constraint.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Bu tür parametresi için bir `nesneyi genişletir` kısıtlaması gerekiyor olabilir.]]></Val>
|
||||
<Val><![CDATA[Bu tür parametresinin bir `extends {0}` kısıtlamasına ihtiyacı olabilir.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -14426,6 +14507,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' örnek üyesi değişkeninin türü, oluşturucuda bildirilen '{1}' tanımlayıcısına başvuramaz.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.]]></Val>
|
||||
@@ -14672,6 +14762,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types cannot appear in export declarations in JavaScript files.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Türler, JavaScript dosyalarında dışarı aktarma bildirimlerinde görünemez.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Types_have_separate_declarations_of_a_private_property_0_2442" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Types have separate declarations of a private property '{0}'.]]></Val>
|
||||
@@ -15368,6 +15467,24 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in a 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Bir 'node_modules' klasöründe tanımlanan öğeler yeniden adlandırılamaz.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in another 'node_modules' folder.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Başka bir 'node_modules' klasöründe tanımlanan öğeler yeniden adlandırılamaz.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[You cannot rename elements that are defined in the standard TypeScript library.]]></Val>
|
||||
@@ -15611,6 +15728,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' bir tür ve JavaScript dosyalarında içeri aktarılamaz. Bir JSDoc türü ek açıklamasında '{1}' kullanın.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.]]></Val>
|
||||
@@ -15638,6 +15764,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_automatically_exported_here_18044" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is automatically exported here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' burada otomatik olarak dışarı aktarılır.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";_0_is_declared_but_its_value_is_never_read_6133" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['{0}' is declared but its value is never read.]]></Val>
|
||||
|
||||
@@ -892,13 +892,13 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
setDocument(key: DocumentRegistryBucketKey, path: Path, sourceFile: SourceFile) {
|
||||
setDocument(key: DocumentRegistryBucketKeyWithMode, path: Path, sourceFile: SourceFile) {
|
||||
const info = Debug.checkDefined(this.getScriptInfoForPath(path));
|
||||
info.cacheSourceFile = { key, sourceFile };
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
getDocument(key: DocumentRegistryBucketKey, path: Path): SourceFile | undefined {
|
||||
getDocument(key: DocumentRegistryBucketKeyWithMode, path: Path): SourceFile | undefined {
|
||||
const info = this.getScriptInfoForPath(path);
|
||||
return info && info.cacheSourceFile && info.cacheSourceFile.key === key ? info.cacheSourceFile.sourceFile : undefined;
|
||||
}
|
||||
@@ -1709,7 +1709,7 @@ namespace ts.server {
|
||||
// created when any of the script infos are added as root of inferred project
|
||||
if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) {
|
||||
// If we cannot watch config file existence without configured project, close the configured file watcher
|
||||
if (!canWatchDirectory(getDirectoryPath(canonicalConfigFilePath) as Path)) {
|
||||
if (!canWatchDirectoryOrFile(getDirectoryPath(canonicalConfigFilePath) as Path)) {
|
||||
configFileExistenceInfo.watcher!.close();
|
||||
configFileExistenceInfo.watcher = noopConfigFileWatcher;
|
||||
}
|
||||
@@ -1794,7 +1794,7 @@ namespace ts.server {
|
||||
(configFileExistenceInfo.openFilesImpactedByConfigFile ||= new Map()).set(info.path, true);
|
||||
|
||||
// If there is no configured project for this config file, add the file watcher
|
||||
configFileExistenceInfo.watcher ||= canWatchDirectory(getDirectoryPath(canonicalConfigFilePath) as Path) ?
|
||||
configFileExistenceInfo.watcher ||= canWatchDirectoryOrFile(getDirectoryPath(canonicalConfigFilePath) as Path) ?
|
||||
this.watchFactory.watchFile(
|
||||
configFileName,
|
||||
(_filename, eventKind) => this.onConfigFileChanged(canonicalConfigFilePath, eventKind),
|
||||
@@ -4185,11 +4185,11 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
getPackageJsonsVisibleToFile(fileName: string, rootDir?: string): readonly PackageJsonInfo[] {
|
||||
getPackageJsonsVisibleToFile(fileName: string, rootDir?: string): readonly ProjectPackageJsonInfo[] {
|
||||
const packageJsonCache = this.packageJsonCache;
|
||||
const rootPath = rootDir && this.toPath(rootDir);
|
||||
const filePath = this.toPath(fileName);
|
||||
const result: PackageJsonInfo[] = [];
|
||||
const result: ProjectPackageJsonInfo[] = [];
|
||||
const processDirectory = (directory: Path): boolean | undefined => {
|
||||
switch (packageJsonCache.directoryHasPackageJson(directory)) {
|
||||
// Sync and check same directory again
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
namespace ts.server {
|
||||
export interface PackageJsonCache {
|
||||
addOrUpdate(fileName: Path): void;
|
||||
forEach(action: (info: PackageJsonInfo, fileName: Path) => void): void;
|
||||
forEach(action: (info: ProjectPackageJsonInfo, fileName: Path) => void): void;
|
||||
delete(fileName: Path): void;
|
||||
get(fileName: Path): PackageJsonInfo | false | undefined;
|
||||
getInDirectory(directory: Path): PackageJsonInfo | undefined;
|
||||
get(fileName: Path): ProjectPackageJsonInfo | false | undefined;
|
||||
getInDirectory(directory: Path): ProjectPackageJsonInfo | undefined;
|
||||
directoryHasPackageJson(directory: Path): Ternary;
|
||||
searchDirectoryAndAncestors(directory: Path): void;
|
||||
}
|
||||
|
||||
export function createPackageJsonCache(host: ProjectService): PackageJsonCache {
|
||||
const packageJsons = new Map<string, PackageJsonInfo>();
|
||||
const packageJsons = new Map<string, ProjectPackageJsonInfo>();
|
||||
const directoriesWithoutPackageJson = new Map<string, true>();
|
||||
return {
|
||||
addOrUpdate,
|
||||
|
||||
@@ -558,7 +558,7 @@ namespace ts.server {
|
||||
cb,
|
||||
PollingInterval.High,
|
||||
this.projectService.getWatchOptions(this),
|
||||
WatchType.PackageJson,
|
||||
WatchType.AffectingFileLocation,
|
||||
this
|
||||
);
|
||||
}
|
||||
@@ -709,7 +709,8 @@ namespace ts.server {
|
||||
this.program!,
|
||||
scriptInfo.path,
|
||||
this.cancellationToken,
|
||||
maybeBind(this.projectService.host, this.projectService.host.createHash)
|
||||
maybeBind(this.projectService.host, this.projectService.host.createHash),
|
||||
this.getCanonicalFileName,
|
||||
),
|
||||
sourceFile => this.shouldEmitFile(this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined
|
||||
);
|
||||
@@ -1171,7 +1172,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private updateGraphWorker() {
|
||||
const oldProgram = this.program;
|
||||
const oldProgram = this.languageService.getCurrentProgram();
|
||||
Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
|
||||
this.writeLog(`Starting updateGraphWorker: Project: ${this.getProjectName()}`);
|
||||
const start = timestamp();
|
||||
@@ -1180,7 +1181,7 @@ namespace ts.server {
|
||||
this.program = this.languageService.getProgram(); // TODO: GH#18217
|
||||
this.dirty = false;
|
||||
tracing?.push(tracing.Phase.Session, "finishCachingPerDirectoryResolution");
|
||||
this.resolutionCache.finishCachingPerDirectoryResolution();
|
||||
this.resolutionCache.finishCachingPerDirectoryResolution(this.program, oldProgram);
|
||||
tracing?.pop();
|
||||
|
||||
Debug.assert(oldProgram === undefined || this.program !== undefined);
|
||||
@@ -1750,7 +1751,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
getPackageJsonsVisibleToFile(fileName: string, rootDir?: string): readonly PackageJsonInfo[] {
|
||||
getPackageJsonsVisibleToFile(fileName: string, rootDir?: string): readonly ProjectPackageJsonInfo[] {
|
||||
if (this.projectService.serverMode !== LanguageServiceMode.Semantic) return emptyArray;
|
||||
return this.projectService.getPackageJsonsVisibleToFile(fileName, rootDir);
|
||||
}
|
||||
@@ -1761,7 +1762,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
getPackageJsonsForAutoImport(rootDir?: string): readonly PackageJsonInfo[] {
|
||||
getPackageJsonsForAutoImport(rootDir?: string): readonly ProjectPackageJsonInfo[] {
|
||||
const packageJsons = this.getPackageJsonsVisibleToFile(combinePaths(this.currentDirectory, inferredTypesContainingFile), rootDir);
|
||||
this.packageJsonsForAutoImport = new Set(packageJsons.map(p => p.fileName));
|
||||
return packageJsons;
|
||||
@@ -2176,7 +2177,6 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
type PackageJsonInfo = NonNullable<ReturnType<typeof resolvePackageNameToPackageJson>>;
|
||||
function getRootNamesFromPackageJson(packageJson: PackageJsonInfo, program: Program, symlinkCache: SymlinkCache, resolveJs?: boolean) {
|
||||
const entrypoints = getEntrypointsFromPackageJsonInfo(
|
||||
packageJson,
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace ts.server {
|
||||
|
||||
/*@internal*/
|
||||
export interface DocumentRegistrySourceFileCache {
|
||||
key: DocumentRegistryBucketKey;
|
||||
key: DocumentRegistryBucketKeyWithMode;
|
||||
sourceFile: SourceFile;
|
||||
}
|
||||
|
||||
|
||||
+13
-23
@@ -344,6 +344,8 @@ namespace ts.server {
|
||||
function getDefinitionLocation(defaultProject: Project, initialLocation: DocumentPosition, isForRename: boolean): DocumentPosition | undefined {
|
||||
const infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename);
|
||||
const info = infos && firstOrUndefined(infos);
|
||||
// Note that the value of `isLocal` may depend on whether or not the checker has run on the containing file
|
||||
// (implying that FAR cascading behavior may depend on request order)
|
||||
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
||||
}
|
||||
|
||||
@@ -504,18 +506,18 @@ namespace ts.server {
|
||||
// If `getResultsForPosition` returns results for a project, they go in here
|
||||
const resultsMap = new Map<Project, readonly TResult[]>();
|
||||
|
||||
const queue: ProjectAndLocation[] = [];
|
||||
const queue = createQueue<ProjectAndLocation>();
|
||||
|
||||
// In order to get accurate isDefinition values for `defaultProject`,
|
||||
// we need to ensure that it is searched from `initialLocation`.
|
||||
// The easiest way to do this is to search it first.
|
||||
queue.push({ project: defaultProject, location: initialLocation });
|
||||
queue.enqueue({ project: defaultProject, location: initialLocation });
|
||||
|
||||
// This will queue `defaultProject` a second time, but it will be dropped
|
||||
// as a dup when it is dequeued.
|
||||
forEachProjectInProjects(projects, initialLocation.fileName, (project, path) => {
|
||||
const location = { fileName: path!, pos: initialLocation.pos };
|
||||
queue.push({ project, location });
|
||||
queue.enqueue({ project, location });
|
||||
});
|
||||
|
||||
const projectService = defaultProject.projectService;
|
||||
@@ -536,25 +538,13 @@ namespace ts.server {
|
||||
const searchedProjectKeys = new Set<string>();
|
||||
|
||||
onCancellation:
|
||||
while (queue.length) {
|
||||
while (queue.length) {
|
||||
while (!queue.isEmpty()) {
|
||||
while (!queue.isEmpty()) {
|
||||
if (cancellationToken.isCancellationRequested()) break onCancellation;
|
||||
|
||||
let skipCount = 0;
|
||||
for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++);
|
||||
|
||||
if (skipCount === queue.length) {
|
||||
queue.length = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (skipCount > 0) {
|
||||
queue.splice(0, skipCount);
|
||||
}
|
||||
|
||||
// NB: we may still skip if it's a project reference redirect
|
||||
const { project, location } = queue.shift()!;
|
||||
const { project, location } = queue.dequeue();
|
||||
|
||||
if (resultsMap.has(project)) continue;
|
||||
if (isLocationProjectReferenceRedirect(project, location)) continue;
|
||||
|
||||
const projectResults = searchPosition(project, location);
|
||||
@@ -574,7 +564,7 @@ namespace ts.server {
|
||||
if (resultsMap.has(project)) return; // Can loop forever without this (enqueue here, dequeue above, repeat)
|
||||
const location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
|
||||
if (location) {
|
||||
queue.push({ project, location });
|
||||
queue.enqueue({ project, location });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -604,7 +594,7 @@ namespace ts.server {
|
||||
|
||||
for (const project of originalScriptInfo.containingProjects) {
|
||||
if (!project.isOrphan() && !resultsMap.has(project)) { // Optimization: don't enqueue if will be discarded
|
||||
queue.push({ project, location: originalLocation });
|
||||
queue.enqueue({ project, location: originalLocation });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,7 +603,7 @@ namespace ts.server {
|
||||
symlinkedProjectsMap.forEach((symlinkedProjects, symlinkedPath) => {
|
||||
for (const symlinkedProject of symlinkedProjects) {
|
||||
if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
|
||||
queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath as string, pos: originalLocation.pos } });
|
||||
queue.enqueue({ project: symlinkedProject, location: { fileName: symlinkedPath as string, pos: originalLocation.pos } });
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1388,7 +1378,7 @@ namespace ts.server {
|
||||
const packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex);
|
||||
const packageJsonCache = project.getModuleResolutionCache()?.getPackageJsonInfoCache();
|
||||
const compilerOptions = project.getCompilationSettings();
|
||||
const packageJson = getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions);
|
||||
const packageJson = getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), getTemporaryModuleResolutionState(packageJsonCache, project, compilerOptions));
|
||||
if (!packageJson) return undefined;
|
||||
// Use fake options instead of actual compiler options to avoid following export map if the project uses node16 or nodenext -
|
||||
// Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be
|
||||
|
||||
@@ -16,50 +16,103 @@ namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes,
|
||||
getCodeActions(context) {
|
||||
const { sourceFile, span, program } = context;
|
||||
const related = getDiagnosticRelatedInfo(program, sourceFile, span);
|
||||
if (!related) {
|
||||
return;
|
||||
}
|
||||
const changes = textChanges.ChangeTracker.with(context, t => addMissingConstraint(t, related));
|
||||
const { sourceFile, span, program, preferences, host } = context;
|
||||
const info = getInfo(program, sourceFile, span);
|
||||
if (info === undefined) return;
|
||||
|
||||
const changes = textChanges.ChangeTracker.with(context, t => addMissingConstraint(t, program, preferences, host, sourceFile, info));
|
||||
return [createCodeFixAction(fixId, changes, Diagnostics.Add_extends_constraint, fixId, Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
|
||||
if (!info) return;
|
||||
return addMissingConstraint(changes, info);
|
||||
}),
|
||||
getAllCodeActions: context => {
|
||||
const { program, preferences, host } = context;
|
||||
const seen = new Map<number, true>();
|
||||
|
||||
return createCombinedCodeActions(textChanges.ChangeTracker.with(context, changes => {
|
||||
eachDiagnostic(context, errorCodes, diag => {
|
||||
const info = getInfo(program, diag.file, createTextSpan(diag.start, diag.length));
|
||||
if (info) {
|
||||
if (addToSeen(seen, getNodeId(info.declaration))) {
|
||||
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
function getDiagnosticRelatedInfo(program: Program, sourceFile: SourceFile, span: TextSpan) {
|
||||
const diag = find(program.getSemanticDiagnostics(sourceFile), diag => diag.start === span.start && diag.length === span.length);
|
||||
if (!diag || !diag.relatedInformation) return;
|
||||
const related = find(diag.relatedInformation, related => related.code === Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code);
|
||||
if (!related) return;
|
||||
return related;
|
||||
interface Info {
|
||||
constraint: Type | string;
|
||||
declaration: TypeParameterDeclaration;
|
||||
token: Node;
|
||||
}
|
||||
|
||||
function addMissingConstraint(changes: textChanges.ChangeTracker, related: DiagnosticRelatedInformation): void {
|
||||
let decl = findAncestorMatchingSpan(related.file!, related as TextSpan);
|
||||
if (!decl) return;
|
||||
if (isIdentifier(decl) && isTypeParameterDeclaration(decl.parent)) {
|
||||
decl = decl.parent;
|
||||
}
|
||||
if (!isTypeParameterDeclaration(decl) || isMappedTypeNode(decl.parent)) return; // should only issue fix on type parameters written using `extends`
|
||||
const newConstraint = flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
||||
if (!newConstraint) return;
|
||||
const newConstraintText = newConstraint[1];
|
||||
function getInfo(program: Program, sourceFile: SourceFile, span: TextSpan): Info | undefined {
|
||||
const diag = find(program.getSemanticDiagnostics(sourceFile), diag => diag.start === span.start && diag.length === span.length);
|
||||
if (diag === undefined || diag.relatedInformation === undefined) return;
|
||||
|
||||
changes.insertText(related.file!, related.start! + related.length!, ` extends ${newConstraintText}`);
|
||||
const related = find(diag.relatedInformation, related => related.code === Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code);
|
||||
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined) return;
|
||||
|
||||
let declaration = findAncestorMatchingSpan(related.file, createTextSpan(related.start, related.length));
|
||||
if (declaration === undefined) return;
|
||||
|
||||
if (isIdentifier(declaration) && isTypeParameterDeclaration(declaration.parent)) {
|
||||
declaration = declaration.parent;
|
||||
}
|
||||
|
||||
if (isTypeParameterDeclaration(declaration)) {
|
||||
// should only issue fix on type parameters written using `extends`
|
||||
if (isMappedTypeNode(declaration.parent)) return;
|
||||
|
||||
const token = getTokenAtPosition(sourceFile, span.start);
|
||||
const checker = program.getTypeChecker();
|
||||
const constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText);
|
||||
|
||||
return { constraint, declaration, token };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function addMissingConstraint(changes: textChanges.ChangeTracker, program: Program, preferences: UserPreferences, host: LanguageServiceHost, sourceFile: SourceFile, info: Info): void {
|
||||
const { declaration, constraint } = info;
|
||||
const checker = program.getTypeChecker();
|
||||
|
||||
if (isString(constraint)) {
|
||||
changes.insertText(sourceFile, declaration.name.end, ` extends ${constraint}`);
|
||||
}
|
||||
else {
|
||||
const scriptTarget = getEmitScriptTarget(program.getCompilerOptions());
|
||||
const tracker = getNoopSymbolTrackerWithResolver({ program, host });
|
||||
const importAdder = createImportAdder(sourceFile, program, preferences, host);
|
||||
const typeNode = typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker);
|
||||
if (typeNode) {
|
||||
changes.replaceNode(sourceFile, declaration, factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default));
|
||||
importAdder.writeFixes(changes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findAncestorMatchingSpan(sourceFile: SourceFile, span: TextSpan): Node {
|
||||
let token = getTokenAtPosition(sourceFile, span.start);
|
||||
const end = textSpanEnd(span);
|
||||
let token = getTokenAtPosition(sourceFile, span.start);
|
||||
while (token.end < end) {
|
||||
token = token.parent;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
function tryGetConstraintFromDiagnosticMessage(messageText: string | DiagnosticMessageChain) {
|
||||
const [_, constraint] = flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [];
|
||||
return constraint;
|
||||
}
|
||||
|
||||
function tryGetConstraintType(checker: TypeChecker, node: Node) {
|
||||
if (isTypeNode(node.parent)) {
|
||||
return checker.getTypeArgumentConstraint(node.parent);
|
||||
}
|
||||
const contextualType = isExpression(node) ? checker.getContextualType(node) : undefined;
|
||||
return contextualType || checker.getTypeAtLocation(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace ts.codefix {
|
||||
return { kind: InfoKind.JsxAttributes, token, attributes, parentDeclaration: token.parent };
|
||||
}
|
||||
|
||||
if (isIdentifier(token) && isCallExpression(parent)) {
|
||||
if (isIdentifier(token) && isCallExpression(parent) && parent.expression === token) {
|
||||
return { kind: InfoKind.Function, token, call: parent, sourceFile, modifierFlags: ModifierFlags.None, parentDeclaration: sourceFile };
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ namespace ts.codefix {
|
||||
const checker = context.program.getTypeChecker();
|
||||
const props = map(info.properties, prop => {
|
||||
const initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration);
|
||||
return factory.createPropertyAssignment(createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === QuotePreference.Single), initializer);
|
||||
return factory.createPropertyAssignment(createPropertyNameFromSymbol(prop, target, quotePreference, checker), initializer);
|
||||
});
|
||||
const options = {
|
||||
leadingTriviaOption: textChanges.LeadingTriviaOption.Exclude,
|
||||
@@ -608,4 +608,14 @@ namespace ts.codefix {
|
||||
const declaration = findAncestor(callExpression, n => isMethodDeclaration(n) || isConstructorDeclaration(n));
|
||||
return declaration && declaration.parent === node ? declaration : undefined;
|
||||
}
|
||||
|
||||
function createPropertyNameFromSymbol(symbol: Symbol, target: ScriptTarget, quotePreference: QuotePreference, checker: TypeChecker) {
|
||||
if (isTransientSymbol(symbol) && symbol.nameType && symbol.nameType.flags & TypeFlags.UniqueESSymbol) {
|
||||
const expression = checker.symbolToExpression((symbol.nameType as UniqueESSymbolType).symbol, SymbolFlags.Value, symbol.valueDeclaration, NodeBuilderFlags.AllowUniqueESSymbolType);
|
||||
if (expression) {
|
||||
return factory.createComputedPropertyName(expression);
|
||||
}
|
||||
}
|
||||
return createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === QuotePreference.Single);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace ts.codefix {
|
||||
// If there is more than one overload but no implementation signature
|
||||
// (eg: an abstract method or interface declaration), there is a 1-1
|
||||
// correspondence of declarations and signatures.
|
||||
const signatures = checker.getSignaturesOfType(type, SignatureKind.Call);
|
||||
const signatures = type.isUnion() ? flatMap(type.types, t => t.getCallSignatures()) : type.getCallSignatures();
|
||||
if (!some(signatures)) {
|
||||
break;
|
||||
}
|
||||
@@ -295,8 +295,10 @@ namespace ts.codefix {
|
||||
const contextualType = isJs ? undefined : checker.getContextualType(call);
|
||||
const names = map(args, arg =>
|
||||
isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) && isIdentifier(arg.name) ? arg.name.text : undefined);
|
||||
const types = isJs ? [] : map(args, arg =>
|
||||
typeToAutoImportableTypeNode(checker, importAdder, checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, scriptTarget, /*flags*/ undefined, tracker));
|
||||
const instanceTypes = isJs ? [] : map(args, arg => checker.getTypeAtLocation(arg));
|
||||
const { argumentTypeNodes, argumentTypeParameters } = getArgumentTypesAndTypeParameters(
|
||||
checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker
|
||||
);
|
||||
|
||||
const modifiers = modifierFlags
|
||||
? factory.createNodeArray(factory.createModifiersFromModifierFlags(modifierFlags))
|
||||
@@ -304,11 +306,8 @@ namespace ts.codefix {
|
||||
const asteriskToken = isYieldExpression(parent)
|
||||
? factory.createToken(SyntaxKind.AsteriskToken)
|
||||
: undefined;
|
||||
const typeParameters = isJs || typeArguments === undefined
|
||||
? undefined
|
||||
: map(typeArguments, (_, i) =>
|
||||
factory.createTypeParameterDeclaration(/*modifiers*/ undefined, CharacterCodes.T + typeArguments.length - 1 <= CharacterCodes.Z ? String.fromCharCode(CharacterCodes.T + i) : `T${i}`));
|
||||
const parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
|
||||
const typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments);
|
||||
const parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs);
|
||||
const type = isJs || contextualType === undefined
|
||||
? undefined
|
||||
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
||||
@@ -349,6 +348,35 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
interface ArgumentTypeParameterAndConstraint {
|
||||
argumentType: Type;
|
||||
constraint?: TypeNode;
|
||||
}
|
||||
|
||||
function createTypeParametersForArguments(checker: TypeChecker, argumentTypeParameters: [string, ArgumentTypeParameterAndConstraint | undefined][], typeArguments: NodeArray<TypeNode> | undefined) {
|
||||
const usedNames = new Set(argumentTypeParameters.map(pair => pair[0]));
|
||||
const constraintsByName = new Map(argumentTypeParameters);
|
||||
|
||||
if (typeArguments) {
|
||||
const typeArgumentsWithNewTypes = typeArguments.filter(typeArgument => !argumentTypeParameters.some(pair => checker.getTypeAtLocation(typeArgument) === pair[1]?.argumentType));
|
||||
const targetSize = usedNames.size + typeArgumentsWithNewTypes.length;
|
||||
for (let i = 0; usedNames.size < targetSize; i += 1) {
|
||||
usedNames.add(createTypeParameterName(i));
|
||||
}
|
||||
}
|
||||
|
||||
return map(
|
||||
arrayFrom(usedNames.values()),
|
||||
usedName => factory.createTypeParameterDeclaration(/*modifiers*/ undefined, usedName, constraintsByName.get(usedName)?.constraint),
|
||||
);
|
||||
}
|
||||
|
||||
function createTypeParameterName(index: number) {
|
||||
return CharacterCodes.T + index <= CharacterCodes.Z
|
||||
? String.fromCharCode(CharacterCodes.T + index)
|
||||
: `T${index}`;
|
||||
}
|
||||
|
||||
export function typeToAutoImportableTypeNode(checker: TypeChecker, importAdder: ImportAdder, type: Type, contextNode: Node | undefined, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined {
|
||||
let typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
|
||||
if (typeNode && isImportTypeNode(typeNode)) {
|
||||
@@ -358,19 +386,124 @@ namespace ts.codefix {
|
||||
typeNode = importableReference.typeNode;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure nodes are fresh so they can have different positions when going through formatting.
|
||||
return getSynthesizedDeepClone(typeNode);
|
||||
}
|
||||
|
||||
function typeContainsTypeParameter(type: Type) {
|
||||
if (type.isUnionOrIntersection()) {
|
||||
return type.types.some(typeContainsTypeParameter);
|
||||
}
|
||||
|
||||
return type.flags & TypeFlags.TypeParameter;
|
||||
}
|
||||
|
||||
export function getArgumentTypesAndTypeParameters(checker: TypeChecker, importAdder: ImportAdder, instanceTypes: Type[], contextNode: Node | undefined, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, tracker?: SymbolTracker) {
|
||||
// Types to be used as the types of the parameters in the new function
|
||||
// E.g. from this source:
|
||||
// added("", 0)
|
||||
// The value will look like:
|
||||
// [{ typeName: { text: "string" } }, { typeName: { text: "number" }]
|
||||
// And in the output function will generate:
|
||||
// function added(a: string, b: number) { ... }
|
||||
const argumentTypeNodes: TypeNode[] = [];
|
||||
|
||||
// Names of type parameters provided as arguments to the call
|
||||
// E.g. from this source:
|
||||
// added<T, U>(value);
|
||||
// The value will look like:
|
||||
// [
|
||||
// ["T", { argumentType: { typeName: { text: "T" } } } ],
|
||||
// ["U", { argumentType: { typeName: { text: "U" } } } ],
|
||||
// ]
|
||||
// And in the output function will generate:
|
||||
// function added<T, U>() { ... }
|
||||
const argumentTypeParameters = new Map<string, ArgumentTypeParameterAndConstraint | undefined>();
|
||||
|
||||
for (let i = 0; i < instanceTypes.length; i += 1) {
|
||||
const instanceType = instanceTypes[i];
|
||||
|
||||
// If the instance type contains a deep reference to an existing type parameter,
|
||||
// instead of copying the full union or intersection, create a new type parameter
|
||||
// E.g. from this source:
|
||||
// function existing<T, U>(value: T | U & string) {
|
||||
// added/*1*/(value);
|
||||
// We don't want to output this:
|
||||
// function added<T>(value: T | U & string) { ... }
|
||||
// We instead want to output:
|
||||
// function added<T>(value: T) { ... }
|
||||
if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) {
|
||||
const synthesizedTypeParameterName = createTypeParameterName(i);
|
||||
argumentTypeNodes.push(factory.createTypeReferenceNode(synthesizedTypeParameterName));
|
||||
argumentTypeParameters.set(synthesizedTypeParameterName, undefined);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
|
||||
const widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType);
|
||||
const argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker);
|
||||
if (!argumentTypeNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
argumentTypeNodes.push(argumentTypeNode);
|
||||
const argumentTypeParameter = getFirstTypeParameterName(instanceType);
|
||||
|
||||
// If the instance type is a type parameter with a constraint (other than an anonymous object),
|
||||
// remember that constraint for when we create the new type parameter
|
||||
// E.g. from this source:
|
||||
// function existing<T extends string>(value: T) {
|
||||
// added/*1*/(value);
|
||||
// We don't want to output this:
|
||||
// function added<T>(value: T) { ... }
|
||||
// We instead want to output:
|
||||
// function added<T extends string>(value: T) { ... }
|
||||
const instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint)
|
||||
? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker)
|
||||
: undefined;
|
||||
|
||||
if (argumentTypeParameter) {
|
||||
argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint });
|
||||
}
|
||||
}
|
||||
|
||||
return { argumentTypeNodes, argumentTypeParameters: arrayFrom(argumentTypeParameters.entries()) };
|
||||
}
|
||||
|
||||
function isAnonymousObjectConstraintType(type: Type) {
|
||||
return (type.flags & TypeFlags.Object) && (type as ObjectType).objectFlags === ObjectFlags.Anonymous;
|
||||
}
|
||||
|
||||
function getFirstTypeParameterName(type: Type): string | undefined {
|
||||
if (type.flags & (TypeFlags.Union | TypeFlags.Intersection)) {
|
||||
for (const subType of (type as UnionType | IntersectionType).types) {
|
||||
const subTypeName = getFirstTypeParameterName(subType);
|
||||
if (subTypeName) {
|
||||
return subTypeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return type.flags & TypeFlags.TypeParameter
|
||||
? type.getSymbol()?.getName()
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function createDummyParameters(argCount: number, names: (string | undefined)[] | undefined, types: (TypeNode | undefined)[] | undefined, minArgumentCount: number | undefined, inJs: boolean): ParameterDeclaration[] {
|
||||
const parameters: ParameterDeclaration[] = [];
|
||||
const parameterNameCounts = new Map<string, number>();
|
||||
for (let i = 0; i < argCount; i++) {
|
||||
const parameterName = names?.[i] || `arg${i}`;
|
||||
const parameterNameCount = parameterNameCounts.get(parameterName);
|
||||
parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1);
|
||||
|
||||
const newParameter = factory.createParameterDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
/*name*/ names && names[i] || `arg${i}`,
|
||||
/*name*/ parameterName + (parameterNameCount || ""),
|
||||
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? factory.createToken(SyntaxKind.QuestionToken) : undefined,
|
||||
/*type*/ inJs ? undefined : types && types[i] || factory.createKeywordTypeNode(SyntaxKind.UnknownKeyword),
|
||||
/*type*/ inJs ? undefined : types?.[i] || factory.createKeywordTypeNode(SyntaxKind.UnknownKeyword),
|
||||
/*initializer*/ undefined);
|
||||
parameters.push(newParameter);
|
||||
}
|
||||
|
||||
+56
-78
@@ -507,87 +507,61 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
const entries = createSortedArray<CompletionEntry>();
|
||||
|
||||
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
||||
const uniqueNames = getCompletionEntriesFromSymbols(
|
||||
symbols,
|
||||
entries,
|
||||
/*replacementToken*/ undefined,
|
||||
contextToken,
|
||||
location,
|
||||
sourceFile,
|
||||
host,
|
||||
program,
|
||||
getEmitScriptTarget(compilerOptions),
|
||||
log,
|
||||
completionKind,
|
||||
preferences,
|
||||
compilerOptions,
|
||||
formatContext,
|
||||
isTypeOnlyLocation,
|
||||
propertyAccessToConvert,
|
||||
isJsxIdentifierExpected,
|
||||
isJsxInitializer,
|
||||
importCompletionNode,
|
||||
recommendedCompletion,
|
||||
symbolToOriginInfoMap,
|
||||
symbolToSortTextMap,
|
||||
isJsxIdentifierExpected,
|
||||
isRightOfOpenTag,
|
||||
);
|
||||
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
|
||||
}
|
||||
else {
|
||||
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === KeywordCompletionFilters.None) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getCompletionEntriesFromSymbols(
|
||||
symbols,
|
||||
entries,
|
||||
/*replacementToken*/ undefined,
|
||||
contextToken,
|
||||
location,
|
||||
sourceFile,
|
||||
host,
|
||||
program,
|
||||
getEmitScriptTarget(compilerOptions),
|
||||
log,
|
||||
completionKind,
|
||||
preferences,
|
||||
compilerOptions,
|
||||
formatContext,
|
||||
isTypeOnlyLocation,
|
||||
propertyAccessToConvert,
|
||||
isJsxIdentifierExpected,
|
||||
isJsxInitializer,
|
||||
importCompletionNode,
|
||||
recommendedCompletion,
|
||||
symbolToOriginInfoMap,
|
||||
symbolToSortTextMap,
|
||||
isJsxIdentifierExpected,
|
||||
isRightOfOpenTag,
|
||||
);
|
||||
const isChecked = isCheckedFile(sourceFile, compilerOptions);
|
||||
if (isChecked && !isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === KeywordCompletionFilters.None) {
|
||||
return undefined;
|
||||
}
|
||||
const uniqueNames = getCompletionEntriesFromSymbols(
|
||||
symbols,
|
||||
entries,
|
||||
/*replacementToken*/ undefined,
|
||||
contextToken,
|
||||
location,
|
||||
sourceFile,
|
||||
host,
|
||||
program,
|
||||
getEmitScriptTarget(compilerOptions),
|
||||
log,
|
||||
completionKind,
|
||||
preferences,
|
||||
compilerOptions,
|
||||
formatContext,
|
||||
isTypeOnlyLocation,
|
||||
propertyAccessToConvert,
|
||||
isJsxIdentifierExpected,
|
||||
isJsxInitializer,
|
||||
importCompletionNode,
|
||||
recommendedCompletion,
|
||||
symbolToOriginInfoMap,
|
||||
symbolToSortTextMap,
|
||||
isJsxIdentifierExpected,
|
||||
isRightOfOpenTag,
|
||||
);
|
||||
|
||||
if (keywordFilters !== KeywordCompletionFilters.None) {
|
||||
const entryNames = new Set(entries.map(e => e.name));
|
||||
for (const keywordEntry of getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && isSourceFileJS(sourceFile))) {
|
||||
if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)!) || !entryNames.has(keywordEntry.name)) {
|
||||
if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)!) || !uniqueNames.has(keywordEntry.name)) {
|
||||
uniqueNames.add(keywordEntry.name);
|
||||
insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const entryNames = new Set(entries.map(e => e.name));
|
||||
for (const keywordEntry of getContextualKeywords(contextToken, position)) {
|
||||
if (!entryNames.has(keywordEntry.name)) {
|
||||
if (!uniqueNames.has(keywordEntry.name)) {
|
||||
uniqueNames.add(keywordEntry.name);
|
||||
insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
for (const literal of literals) {
|
||||
insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
|
||||
const literalEntry = createCompletionEntryForLiteral(sourceFile, preferences, literal);
|
||||
uniqueNames.add(literalEntry.name);
|
||||
insertSorted(entries, literalEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
||||
}
|
||||
|
||||
if (!isChecked) {
|
||||
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -601,8 +575,8 @@ namespace ts.Completions {
|
||||
};
|
||||
}
|
||||
|
||||
function isUncheckedFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
|
||||
return isSourceFileJS(sourceFile) && !isCheckJsEnabledForFile(sourceFile, compilerOptions);
|
||||
function isCheckedFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
|
||||
return !isSourceFileJS(sourceFile) || !!isCheckJsEnabledForFile(sourceFile, compilerOptions);
|
||||
}
|
||||
|
||||
function isMemberCompletionKind(kind: CompletionKind): boolean {
|
||||
@@ -1152,7 +1126,7 @@ namespace ts.Completions {
|
||||
const name = getSynthesizedDeepClone(getNameOfDeclaration(declaration), /*includeTrivia*/ false) as PropertyName;
|
||||
const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
||||
const quotePreference = getQuotePreference(sourceFile, preferences);
|
||||
const builderFlags = quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : undefined;
|
||||
const builderFlags = NodeBuilderFlags.OmitThisParameter | (quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : NodeBuilderFlags.None);
|
||||
|
||||
switch (declaration.kind) {
|
||||
case SyntaxKind.PropertySignature:
|
||||
@@ -1942,7 +1916,7 @@ namespace ts.Completions {
|
||||
cancellationToken?: CancellationToken,
|
||||
): CompletionData | Request | undefined {
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
|
||||
const inCheckedFile = isCheckedFile(sourceFile, compilerOptions);
|
||||
let start = timestamp();
|
||||
let currentToken = getTokenAtPosition(sourceFile, position); // TODO: GH#15853
|
||||
// We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
|
||||
@@ -2396,7 +2370,14 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
const propertyAccess = node.kind === SyntaxKind.ImportType ? node as ImportTypeNode : node.parent as PropertyAccessExpression | QualifiedName;
|
||||
if (inUncheckedFile) {
|
||||
if (inCheckedFile) {
|
||||
for (const symbol of type.getApparentProperties()) {
|
||||
if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) {
|
||||
addPropertySymbol(symbol, /* insertAwait */ false, insertQuestionDot);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// In javascript files, for union types, we don't just get the members that
|
||||
// the individual types have in common, we also include all the members that
|
||||
// each individual type has. This is because we're going to add all identifiers
|
||||
@@ -2404,13 +2385,6 @@ namespace ts.Completions {
|
||||
// of the individual types to a higher status since we know what they are.
|
||||
symbols.push(...filter(getPropertiesForCompletion(type, typeChecker), s => typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s)));
|
||||
}
|
||||
else {
|
||||
for (const symbol of type.getApparentProperties()) {
|
||||
if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) {
|
||||
addPropertySymbol(symbol, /* insertAwait */ false, insertQuestionDot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (insertAwait && preferences.includeCompletionsWithInsertText) {
|
||||
const promiseType = typeChecker.getPromisedTypeOfPromise(type);
|
||||
@@ -4094,6 +4068,10 @@ namespace ts.Completions {
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.Identifier: {
|
||||
const originalKeywordKind = (location as Identifier).originalKeywordKind;
|
||||
if (originalKeywordKind && isKeyword(originalKeywordKind)) {
|
||||
return undefined;
|
||||
}
|
||||
// class c { public prop = c| }
|
||||
if (isPropertyDeclaration(location.parent) && location.parent.initializer === location) {
|
||||
return undefined;
|
||||
|
||||
@@ -37,7 +37,9 @@ namespace ts {
|
||||
compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
scriptKind?: ScriptKind,
|
||||
sourceFileOptions?: CreateSourceFileOptions | ScriptTarget,
|
||||
): SourceFile;
|
||||
|
||||
acquireDocumentWithKey(
|
||||
fileName: string,
|
||||
@@ -46,7 +48,9 @@ namespace ts {
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
scriptKind?: ScriptKind,
|
||||
sourceFileOptions?: CreateSourceFileOptions | ScriptTarget,
|
||||
): SourceFile;
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
@@ -68,7 +72,9 @@ namespace ts {
|
||||
compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
scriptKind?: ScriptKind,
|
||||
sourceFileOptions?: CreateSourceFileOptions | ScriptTarget,
|
||||
): SourceFile;
|
||||
|
||||
updateDocumentWithKey(
|
||||
fileName: string,
|
||||
@@ -77,7 +83,9 @@ namespace ts {
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
scriptKind?: ScriptKind,
|
||||
sourceFileOptions?: CreateSourceFileOptions | ScriptTarget,
|
||||
): SourceFile;
|
||||
|
||||
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
|
||||
/**
|
||||
@@ -88,9 +96,10 @@ namespace ts {
|
||||
*
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
* @param scriptKind The script kind of the file to be released
|
||||
*/
|
||||
/**@deprecated pass scriptKind for correctness */
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
/**@deprecated pass scriptKind and impliedNodeFormat for correctness */
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind?: ScriptKind): void;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
@@ -100,12 +109,13 @@ namespace ts {
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
* @param scriptKind The script kind of the file to be released
|
||||
* @param impliedNodeFormat The implied source file format of the file to be released
|
||||
*/
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind, impliedNodeFormat: SourceFile["impliedNodeFormat"]): void; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
/**
|
||||
* @deprecated pass scriptKind for correctness */
|
||||
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
|
||||
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
* @deprecated pass scriptKind for and impliedNodeFormat correctness */
|
||||
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind?: ScriptKind): void;
|
||||
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind, impliedNodeFormat: SourceFile["impliedNodeFormat"]): void; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
|
||||
/*@internal*/
|
||||
getLanguageServiceRefCounts(path: Path, scriptKind: ScriptKind): [string, number | undefined][];
|
||||
@@ -115,8 +125,8 @@ namespace ts {
|
||||
|
||||
/*@internal*/
|
||||
export interface ExternalDocumentCache {
|
||||
setDocument(key: DocumentRegistryBucketKey, path: Path, sourceFile: SourceFile): void;
|
||||
getDocument(key: DocumentRegistryBucketKey, path: Path): SourceFile | undefined;
|
||||
setDocument(key: DocumentRegistryBucketKeyWithMode, path: Path, sourceFile: SourceFile): void;
|
||||
getDocument(key: DocumentRegistryBucketKeyWithMode, path: Path): SourceFile | undefined;
|
||||
}
|
||||
|
||||
export type DocumentRegistryBucketKey = string & { __bucketKey: any };
|
||||
@@ -139,11 +149,13 @@ namespace ts {
|
||||
return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export type DocumentRegistryBucketKeyWithMode = string & { __documentRegistryBucketKeyWithMode: any; };
|
||||
/*@internal*/
|
||||
export function createDocumentRegistryInternal(useCaseSensitiveFileNames?: boolean, currentDirectory = "", externalCache?: ExternalDocumentCache): DocumentRegistry {
|
||||
// Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have
|
||||
// for those settings.
|
||||
const buckets = new Map<DocumentRegistryBucketKey, ESMap<Path, BucketEntry>>();
|
||||
const buckets = new Map<DocumentRegistryBucketKeyWithMode, ESMap<Path, BucketEntry>>();
|
||||
const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
|
||||
|
||||
function reportStats() {
|
||||
@@ -178,24 +190,24 @@ namespace ts {
|
||||
return settingsOrHost as CompilerOptions;
|
||||
}
|
||||
|
||||
function acquireDocument(fileName: string, compilationSettings: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
function acquireDocument(fileName: string, compilationSettings: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, languageVersionOrOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile {
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
|
||||
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
||||
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
|
||||
}
|
||||
|
||||
function acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
|
||||
function acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, languageVersionOrOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions);
|
||||
}
|
||||
|
||||
function updateDocument(fileName: string, compilationSettings: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
function updateDocument(fileName: string, compilationSettings: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, languageVersionOrOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile {
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
|
||||
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
||||
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
|
||||
}
|
||||
|
||||
function updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
|
||||
function updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, languageVersionOrOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions);
|
||||
}
|
||||
|
||||
function getDocumentRegistryEntry(bucketEntry: BucketEntry, scriptKind: ScriptKind | undefined) {
|
||||
@@ -212,41 +224,46 @@ namespace ts {
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
acquiring: boolean,
|
||||
scriptKind?: ScriptKind): SourceFile {
|
||||
scriptKind: ScriptKind | undefined,
|
||||
languageVersionOrOptions: CreateSourceFileOptions | ScriptTarget | undefined,
|
||||
): SourceFile {
|
||||
scriptKind = ensureScriptKind(fileName, scriptKind);
|
||||
const compilationSettings = getCompilationSettings(compilationSettingsOrHost);
|
||||
const host: MinimalResolutionCacheHost | undefined = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost as MinimalResolutionCacheHost;
|
||||
const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : getEmitScriptTarget(compilationSettings);
|
||||
const sourceFileOptions: CreateSourceFileOptions = {
|
||||
languageVersion: scriptTarget,
|
||||
impliedNodeFormat: host && getImpliedNodeFormatForFile(path, host.getCompilerHost?.()?.getModuleResolutionCache?.()?.getPackageJsonInfoCache(), host, compilationSettings),
|
||||
setExternalModuleIndicator: getSetExternalModuleIndicator(compilationSettings)
|
||||
};
|
||||
|
||||
const sourceFileOptions: CreateSourceFileOptions = typeof languageVersionOrOptions === "object" ?
|
||||
languageVersionOrOptions :
|
||||
{
|
||||
languageVersion: scriptTarget,
|
||||
impliedNodeFormat: host && getImpliedNodeFormatForFile(path, host.getCompilerHost?.()?.getModuleResolutionCache?.()?.getPackageJsonInfoCache(), host, compilationSettings),
|
||||
setExternalModuleIndicator: getSetExternalModuleIndicator(compilationSettings)
|
||||
};
|
||||
sourceFileOptions.languageVersion = scriptTarget;
|
||||
const oldBucketCount = buckets.size;
|
||||
const bucket = getOrUpdate(buckets, key, () => new Map());
|
||||
const keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat);
|
||||
const bucket = getOrUpdate(buckets, keyWithMode, () => new Map());
|
||||
if (tracing) {
|
||||
if (buckets.size > oldBucketCount) {
|
||||
// It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
|
||||
// perhaps they are for two projects that don't have any overlap.
|
||||
// Bonus: these events can help us interpret the more interesting event below.
|
||||
tracing.instant(tracing.Phase.Session, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key });
|
||||
tracing.instant(tracing.Phase.Session, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode });
|
||||
}
|
||||
|
||||
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
||||
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
||||
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
||||
const otherBucketKey = !isDeclarationFileName(path) &&
|
||||
forEachEntry(buckets, (bucket, bucketKey) => bucketKey !== key && bucket.has(path) && bucketKey);
|
||||
forEachEntry(buckets, (bucket, bucketKey) => bucketKey !== keyWithMode && bucket.has(path) && bucketKey);
|
||||
if (otherBucketKey) {
|
||||
tracing.instant(tracing.Phase.Session, "documentRegistryBucketOverlap", { path, key1: otherBucketKey, key2: key });
|
||||
tracing.instant(tracing.Phase.Session, "documentRegistryBucketOverlap", { path, key1: otherBucketKey, key2: keyWithMode });
|
||||
}
|
||||
}
|
||||
|
||||
const bucketEntry = bucket.get(path);
|
||||
let entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
||||
if (!entry && externalCache) {
|
||||
const sourceFile = externalCache.getDocument(key, path);
|
||||
const sourceFile = externalCache.getDocument(keyWithMode, path);
|
||||
if (sourceFile) {
|
||||
Debug.assert(acquiring);
|
||||
entry = {
|
||||
@@ -261,7 +278,7 @@ namespace ts {
|
||||
// Have never seen this file with these settings. Create a new source file for it.
|
||||
const sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
|
||||
if (externalCache) {
|
||||
externalCache.setDocument(key, path, sourceFile);
|
||||
externalCache.setDocument(keyWithMode, path, sourceFile);
|
||||
}
|
||||
entry = {
|
||||
sourceFile,
|
||||
@@ -277,7 +294,7 @@ namespace ts {
|
||||
entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version,
|
||||
scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot!)); // TODO: GH#18217
|
||||
if (externalCache) {
|
||||
externalCache.setDocument(key, path, entry.sourceFile);
|
||||
externalCache.setDocument(keyWithMode, path, entry.sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,14 +327,14 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind?: ScriptKind): void {
|
||||
function releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind?: ScriptKind, impliedNodeFormat?: SourceFile["impliedNodeFormat"]): void {
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return releaseDocumentWithKey(path, key, scriptKind);
|
||||
return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat);
|
||||
}
|
||||
|
||||
function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind?: ScriptKind): void {
|
||||
const bucket = Debug.checkDefined(buckets.get(key));
|
||||
function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind?: ScriptKind, impliedNodeFormat?: SourceFile["impliedNodeFormat"]): void {
|
||||
const bucket = Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat)));
|
||||
const bucketEntry = bucket.get(path)!;
|
||||
const entry = getDocumentRegistryEntry(bucketEntry, scriptKind)!;
|
||||
entry.languageServiceRefCount--;
|
||||
@@ -376,4 +393,8 @@ namespace ts {
|
||||
function getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey {
|
||||
return sourceFileAffectingCompilerOptions.map(option => compilerOptionValueToString(getCompilerOptionValue(settings, option))).join("|") + (settings.pathsBasePath ? `|${settings.pathsBasePath}` : undefined) as DocumentRegistryBucketKey;
|
||||
}
|
||||
|
||||
function getDocumentRegistryBucketKeyWithMode(key: DocumentRegistryBucketKey, mode: ModuleKind.ESNext | ModuleKind.CommonJS | undefined) {
|
||||
return (mode ? `${key}|${mode}` : key) as DocumentRegistryBucketKeyWithMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,18 +240,18 @@ namespace ts.FindAllReferences {
|
||||
) {
|
||||
referenceEntries = entries && [...entries];
|
||||
}
|
||||
else {
|
||||
const queue = entries && [...entries];
|
||||
else if (entries) {
|
||||
const queue = createQueue(entries);
|
||||
const seenNodes = new Map<number, true>();
|
||||
while (queue && queue.length) {
|
||||
const entry = queue.shift() as NodeEntry;
|
||||
while (!queue.isEmpty()) {
|
||||
const entry = queue.dequeue() as NodeEntry;
|
||||
if (!addToSeen(seenNodes, getNodeId(entry.node))) {
|
||||
continue;
|
||||
}
|
||||
referenceEntries = append(referenceEntries, entry);
|
||||
const entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, entry.node, entry.node.pos);
|
||||
if (entries) {
|
||||
queue.push(...entries);
|
||||
queue.enqueue(...entries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,6 +403,7 @@ namespace ts.formatting {
|
||||
|
||||
// formatting context is used by rules provider
|
||||
const formattingContext = new FormattingContext(sourceFile, requestKind, options);
|
||||
let previousRangeTriviaEnd: number;
|
||||
let previousRange: TextRangeWithKind;
|
||||
let previousParent: Node;
|
||||
let previousRangeStartLine: number;
|
||||
@@ -439,12 +440,32 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
if (previousRange! && formattingScanner.getStartPos() >= originalRange.end) {
|
||||
// Formatting edits happen by looking at pairs of contiguous tokens (see `processPair`),
|
||||
// typically inserting or deleting whitespace between them. The recursive `processNode`
|
||||
// logic above bails out as soon as it encounters a token that is beyond the end of the
|
||||
// range we're supposed to format (or if we reach the end of the file). But this potentially
|
||||
// leaves out an edit that would occur *inside* the requested range but cannot be discovered
|
||||
// without looking at one token *beyond* the end of the range: consider the line `x = { }`
|
||||
// with a selection from the beginning of the line to the space inside the curly braces,
|
||||
// inclusive. We would expect a format-selection would delete the space (if rules apply),
|
||||
// but in order to do that, we need to process the pair ["{", "}"], but we stopped processing
|
||||
// just before getting there. This block handles this trailing edit.
|
||||
const tokenInfo =
|
||||
formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
|
||||
formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token :
|
||||
undefined;
|
||||
|
||||
if (tokenInfo) {
|
||||
if (tokenInfo && tokenInfo.pos === previousRangeTriviaEnd!) {
|
||||
// We need to check that tokenInfo and previousRange are contiguous: the `originalRange`
|
||||
// may have ended in the middle of a token, which means we will have stopped formatting
|
||||
// on that token, leaving `previousRange` pointing to the token before it, but already
|
||||
// having moved the formatting scanner (where we just got `tokenInfo`) to the next token.
|
||||
// If this happens, our supposed pair [previousRange, tokenInfo] actually straddles the
|
||||
// token that intersects the end of the range we're supposed to format, so the pair will
|
||||
// produce bogus edits if we try to `processPair`. Recall that the point of this logic is
|
||||
// to perform a trailing edit at the end of the selection range: but there can be no valid
|
||||
// edit in the middle of a token where the range ended, so if we have a non-contiguous
|
||||
// pair here, we're already done and we can ignore it.
|
||||
const parent = findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)?.parent || previousParent!;
|
||||
processPair(
|
||||
tokenInfo,
|
||||
@@ -691,6 +712,7 @@ namespace ts.formatting {
|
||||
undecoratedParentStartLine: number,
|
||||
isListItem: boolean,
|
||||
isFirstListItem?: boolean): number {
|
||||
Debug.assert(!nodeIsSynthesized(child));
|
||||
|
||||
if (nodeIsMissing(child)) {
|
||||
return inheritedIndentation;
|
||||
@@ -778,6 +800,7 @@ namespace ts.formatting {
|
||||
parentStartLine: number,
|
||||
parentDynamicIndentation: DynamicIndentation): void {
|
||||
Debug.assert(isNodeArray(nodes));
|
||||
Debug.assert(!nodeIsSynthesized(nodes));
|
||||
|
||||
const listStartToken = getOpenTokenForList(parent, nodes);
|
||||
|
||||
@@ -886,6 +909,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
if (currentTokenInfo.trailingTrivia) {
|
||||
previousRangeTriviaEnd = last(currentTokenInfo.trailingTrivia).end;
|
||||
processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation);
|
||||
}
|
||||
|
||||
@@ -974,6 +998,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
previousRange = range;
|
||||
previousRangeTriviaEnd = range.end;
|
||||
previousParent = parent;
|
||||
previousRangeStartLine = rangeStart.line;
|
||||
|
||||
|
||||
+11
-3
@@ -357,8 +357,12 @@ namespace ts.JsDoc {
|
||||
}
|
||||
|
||||
const { commentOwner, parameters, hasReturn } = commentOwnerInfo;
|
||||
const commentOwnerJSDoc = hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? lastOrUndefined(commentOwner.jsDoc) : undefined;
|
||||
if (commentOwner.getStart(sourceFile) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment) {
|
||||
const commentOwnerJsDoc = hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? commentOwner.jsDoc : undefined;
|
||||
const lastJsDoc = lastOrUndefined(commentOwnerJsDoc);
|
||||
if (commentOwner.getStart(sourceFile) < position
|
||||
|| lastJsDoc
|
||||
&& existingDocComment
|
||||
&& lastJsDoc !== existingDocComment) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -378,7 +382,11 @@ namespace ts.JsDoc {
|
||||
// * if the caret was directly in front of the object, then we add an extra line and indentation.
|
||||
const openComment = "/**";
|
||||
const closeComment = " */";
|
||||
if (tags) {
|
||||
|
||||
// If any of the existing jsDoc has tags, ignore adding new ones.
|
||||
const hasTag = (commentOwnerJsDoc || []).some(jsDoc => !!jsDoc.tags);
|
||||
|
||||
if (tags && !hasTag) {
|
||||
const preamble = openComment + newLine + indentationStr + " * ";
|
||||
const endLine = tokenStart === position ? newLine + indentationStr : "";
|
||||
const result = preamble + newLine + tags + indentationStr + closeComment + endLine;
|
||||
|
||||
@@ -185,6 +185,10 @@ ${newComment.split("\n").map(c => ` * ${c}`).join("\n")}
|
||||
if (!containingDecl) {
|
||||
return;
|
||||
}
|
||||
if (isFunctionLikeDeclaration(containingDecl) && containingDecl.body && rangeContainsPosition(containingDecl.body, startPosition)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const checker = program.getTypeChecker();
|
||||
const signatureSymbol = containingDecl.symbol;
|
||||
if (!signatureSymbol) {
|
||||
|
||||
@@ -551,7 +551,7 @@ namespace ts.refactor.extractSymbol {
|
||||
const savedPermittedJumps = permittedJumps;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.IfStatement:
|
||||
permittedJumps = PermittedJumps.None;
|
||||
permittedJumps &= ~PermittedJumps.Return;
|
||||
break;
|
||||
case SyntaxKind.TryStatement:
|
||||
// forbid all jumps inside try blocks
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace ts.refactor {
|
||||
|
||||
const currentDirectory = getDirectoryPath(oldFile.fileName);
|
||||
const extension = extensionFromPath(oldFile.fileName);
|
||||
const newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host);
|
||||
const newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host);
|
||||
const newFileNameWithExtension = newModuleName + extension;
|
||||
|
||||
// If previous file was global, this is easy.
|
||||
@@ -478,8 +478,8 @@ namespace ts.refactor {
|
||||
}
|
||||
}
|
||||
|
||||
function getNewModuleName(movedSymbols: ReadonlySymbolSet): string {
|
||||
return movedSymbols.forEachEntry(symbolNameNoDefault) || "newFile";
|
||||
function getNewModuleName(importsFromNewFile: ReadonlySymbolSet, movedSymbols: ReadonlySymbolSet): string {
|
||||
return importsFromNewFile.forEachEntry(symbolNameNoDefault) || movedSymbols.forEachEntry(symbolNameNoDefault) || "newFile";
|
||||
}
|
||||
|
||||
interface UsageInfo {
|
||||
|
||||
+37
-23
@@ -343,20 +343,25 @@ namespace ts {
|
||||
}
|
||||
|
||||
getContextualDocumentationComment(context: Node | undefined, checker: TypeChecker | undefined): SymbolDisplayPart[] {
|
||||
switch (context?.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
if (context) {
|
||||
if (isGetAccessor(context)) {
|
||||
if (!this.contextualGetAccessorDocumentationComment) {
|
||||
this.contextualGetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isGetAccessor), checker);
|
||||
}
|
||||
return this.contextualGetAccessorDocumentationComment;
|
||||
case SyntaxKind.SetAccessor:
|
||||
if (length(this.contextualGetAccessorDocumentationComment)) {
|
||||
return this.contextualGetAccessorDocumentationComment;
|
||||
}
|
||||
}
|
||||
if (isSetAccessor(context)) {
|
||||
if (!this.contextualSetAccessorDocumentationComment) {
|
||||
this.contextualSetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isSetAccessor), checker);
|
||||
}
|
||||
return this.contextualSetAccessorDocumentationComment;
|
||||
default:
|
||||
return this.getDocumentationComment(checker);
|
||||
if (length(this.contextualSetAccessorDocumentationComment)) {
|
||||
return this.contextualSetAccessorDocumentationComment;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.getDocumentationComment(checker);
|
||||
}
|
||||
|
||||
getJsDocTags(checker?: TypeChecker): JSDocTagInfo[] {
|
||||
@@ -368,20 +373,25 @@ namespace ts {
|
||||
}
|
||||
|
||||
getContextualJsDocTags(context: Node | undefined, checker: TypeChecker | undefined): JSDocTagInfo[] {
|
||||
switch (context?.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
if (context) {
|
||||
if (isGetAccessor(context)) {
|
||||
if (!this.contextualGetAccessorTags) {
|
||||
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(filter(this.declarations, isGetAccessor), checker);
|
||||
}
|
||||
return this.contextualGetAccessorTags;
|
||||
case SyntaxKind.SetAccessor:
|
||||
if (length(this.contextualGetAccessorTags)) {
|
||||
return this.contextualGetAccessorTags;
|
||||
}
|
||||
}
|
||||
if (isSetAccessor(context)) {
|
||||
if (!this.contextualSetAccessorTags) {
|
||||
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(filter(this.declarations, isSetAccessor), checker);
|
||||
}
|
||||
return this.contextualSetAccessorTags;
|
||||
default:
|
||||
return this.getJsDocTags(checker);
|
||||
if (length(this.contextualSetAccessorTags)) {
|
||||
return this.contextualSetAccessorTags;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.getJsDocTags(checker);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1283,7 +1293,10 @@ namespace ts {
|
||||
lastTypesRootVersion = typeRootsVersion;
|
||||
}
|
||||
|
||||
const rootFileNames = host.getScriptFileNames();
|
||||
// This array is retained by the program and will be used to determine if the program is up to date,
|
||||
// so we need to make a copy in case the host mutates the underlying array - otherwise it would look
|
||||
// like every program always has the host's current list of root files.
|
||||
const rootFileNames = host.getScriptFileNames().slice();
|
||||
|
||||
// Get a fresh cache of the host information
|
||||
const newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
|
||||
@@ -1426,14 +1439,14 @@ namespace ts {
|
||||
// not part of the new program.
|
||||
function onReleaseOldSourceFile(oldSourceFile: SourceFile, oldOptions: CompilerOptions) {
|
||||
const oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions);
|
||||
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind);
|
||||
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
||||
}
|
||||
|
||||
function getOrCreateSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined {
|
||||
return getOrCreateSourceFileByPath(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile);
|
||||
function getOrCreateSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined {
|
||||
return getOrCreateSourceFileByPath(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
||||
}
|
||||
|
||||
function getOrCreateSourceFileByPath(fileName: string, path: Path, _languageVersion: ScriptTarget, _onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined {
|
||||
function getOrCreateSourceFileByPath(fileName: string, path: Path, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, _onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined {
|
||||
Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
|
||||
// The program is asking for this file, check first if the host can locate it.
|
||||
// If the host can not locate the file, then it does not exist. return undefined
|
||||
@@ -1479,11 +1492,11 @@ namespace ts {
|
||||
// file's script kind, i.e. in one project some file is treated as ".ts"
|
||||
// and in another as ".js"
|
||||
if (scriptKind === oldSourceFile.scriptKind) {
|
||||
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
||||
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
|
||||
}
|
||||
else {
|
||||
// Release old source file and fall through to aquire new file with new script kind
|
||||
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind);
|
||||
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1491,7 +1504,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Could not find this file in the old program, create a new SourceFile for it.
|
||||
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
||||
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1576,7 +1589,7 @@ namespace ts {
|
||||
// Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host
|
||||
const key = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
|
||||
forEach(program.getSourceFiles(), f =>
|
||||
documentRegistry.releaseDocumentWithKey(f.resolvedPath, key, f.scriptKind));
|
||||
documentRegistry.releaseDocumentWithKey(f.resolvedPath, key, f.scriptKind, f.impliedNodeFormat));
|
||||
program = undefined!; // TODO: GH#18217
|
||||
}
|
||||
host = undefined!;
|
||||
@@ -2681,6 +2694,7 @@ namespace ts {
|
||||
getEmitOutput,
|
||||
getNonBoundSourceFile,
|
||||
getProgram,
|
||||
getCurrentProgram: () => program,
|
||||
getAutoImportProvider,
|
||||
updateIsDefinitionOfReferencedSymbols,
|
||||
getApplicableRefactors,
|
||||
|
||||
@@ -52,13 +52,24 @@ namespace ts.SmartSelectionRange {
|
||||
// selected from open to close, including whitespace but not including the braces/etc. themselves.
|
||||
const isBetweenMultiLineBookends = isSyntaxList(node) && isListOpener(prevNode) && isListCloser(nextNode)
|
||||
&& !positionsAreOnSameLine(prevNode.getStart(), nextNode.getStart(), sourceFile);
|
||||
const start = isBetweenMultiLineBookends ? prevNode.getEnd() : node.getStart();
|
||||
let start = isBetweenMultiLineBookends ? prevNode.getEnd() : node.getStart();
|
||||
const end = isBetweenMultiLineBookends ? nextNode.getStart() : getEndPos(sourceFile, node);
|
||||
|
||||
if (hasJSDocNodes(node) && node.jsDoc?.length) {
|
||||
pushSelectionRange(first(node.jsDoc).getStart(), end);
|
||||
}
|
||||
|
||||
// (#39618 & #49807)
|
||||
// When the node is a SyntaxList and its first child has a JSDoc comment, then the node's
|
||||
// `start` (which usually is the result of calling `node.getStart()`) points to the first
|
||||
// token after the JSDoc comment. So, we have to make sure we'd pushed the selection
|
||||
// covering the JSDoc comment before diving further.
|
||||
if (isSyntaxList(node)) {
|
||||
const firstChild = node.getChildren()[0];
|
||||
if (firstChild && hasJSDocNodes(firstChild) && firstChild.jsDoc?.length && firstChild.getStart() !== node.pos) {
|
||||
start = Math.min(start, first(firstChild.jsDoc).getStart());
|
||||
}
|
||||
}
|
||||
pushSelectionRange(start, end);
|
||||
|
||||
// String literals should have a stop both inside and outside their quotes.
|
||||
@@ -184,7 +195,10 @@ namespace ts.SmartSelectionRange {
|
||||
if (isPropertySignature(node)) {
|
||||
const children = groupChildren(node.getChildren(), child =>
|
||||
child === node.name || contains(node.modifiers, child));
|
||||
return splitChildren(children, ({ kind }) => kind === SyntaxKind.ColonToken);
|
||||
const firstJSDocChild = children[0]?.kind === SyntaxKind.JSDoc ? children[0] : undefined;
|
||||
const withJSDocSeparated = firstJSDocChild? children.slice(1) : children;
|
||||
const splittedChildren = splitChildren(withJSDocSeparated, ({ kind }) => kind === SyntaxKind.ColonToken);
|
||||
return firstJSDocChild? [firstJSDocChild, createSyntaxList(splittedChildren)] : splittedChildren;
|
||||
}
|
||||
|
||||
// Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`.
|
||||
|
||||
+192
-105
@@ -1,5 +1,30 @@
|
||||
/* @internal */
|
||||
namespace ts.Completions.StringCompletions {
|
||||
interface NameAndKindSet {
|
||||
add(value: NameAndKind): void;
|
||||
has(name: string): boolean;
|
||||
values(): Iterator<NameAndKind>;
|
||||
}
|
||||
const kindPrecedence = {
|
||||
[ScriptElementKind.directory]: 0,
|
||||
[ScriptElementKind.scriptElement]: 1,
|
||||
[ScriptElementKind.externalModuleName]: 2,
|
||||
};
|
||||
function createNameAndKindSet(): NameAndKindSet {
|
||||
const map = new Map<string, NameAndKind>();
|
||||
function add(value: NameAndKind) {
|
||||
const existing = map.get(value.name);
|
||||
if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) {
|
||||
map.set(value.name, value);
|
||||
}
|
||||
}
|
||||
return {
|
||||
add,
|
||||
has: map.has.bind(map),
|
||||
values: map.values.bind(map),
|
||||
};
|
||||
}
|
||||
|
||||
export function getStringLiteralCompletions(
|
||||
sourceFile: SourceFile,
|
||||
position: number,
|
||||
@@ -142,9 +167,9 @@ namespace ts.Completions.StringCompletions {
|
||||
case SyntaxKind.LiteralType: {
|
||||
const grandParent = walkUpParentheses(parent.parent);
|
||||
switch (grandParent.kind) {
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
case SyntaxKind.TypeReference: {
|
||||
const typeReference = grandParent as TypeReferenceNode;
|
||||
const typeArgument = findAncestor(parent, n => n.parent === typeReference) as LiteralTypeNode;
|
||||
const typeArgument = findAncestor(parent, n => n.parent === grandParent) as LiteralTypeNode;
|
||||
if (typeArgument) {
|
||||
return { kind: StringLiteralCompletionKind.Types, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
|
||||
}
|
||||
@@ -343,13 +368,14 @@ namespace ts.Completions.StringCompletions {
|
||||
|
||||
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker, preferences: UserPreferences): readonly NameAndKind[] {
|
||||
const literalValue = normalizeSlashes(node.text);
|
||||
const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : undefined;
|
||||
|
||||
const scriptPath = sourceFile.path;
|
||||
const scriptDirectory = getDirectoryPath(scriptPath);
|
||||
|
||||
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (isRootedDiskPath(literalValue) || isUrl(literalValue))
|
||||
? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
|
||||
: getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
|
||||
: getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker);
|
||||
|
||||
function getIncludeExtensionOption() {
|
||||
const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : undefined;
|
||||
@@ -371,7 +397,7 @@ namespace ts.Completions.StringCompletions {
|
||||
compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath);
|
||||
}
|
||||
else {
|
||||
return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
|
||||
return arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +442,7 @@ namespace ts.Completions.StringCompletions {
|
||||
const basePath = compilerOptions.project || host.getCurrentDirectory();
|
||||
const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
||||
const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
|
||||
return flatMap(baseDirectories, baseDirectory => getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude));
|
||||
return flatMap(baseDirectories, baseDirectory => arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()));
|
||||
}
|
||||
|
||||
const enum IncludeExtensionsOption {
|
||||
@@ -427,7 +453,14 @@ namespace ts.Completions.StringCompletions {
|
||||
/**
|
||||
* Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
|
||||
*/
|
||||
function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, { extensions, includeExtensionsOption }: ExtensionOptions, host: LanguageServiceHost, exclude?: string, result: NameAndKind[] = []): NameAndKind[] {
|
||||
function getCompletionEntriesForDirectoryFragment(
|
||||
fragment: string,
|
||||
scriptPath: string,
|
||||
extensionOptions: ExtensionOptions,
|
||||
host: LanguageServiceHost,
|
||||
exclude?: string,
|
||||
result = createNameAndKindSet()
|
||||
): NameAndKindSet {
|
||||
if (fragment === undefined) {
|
||||
fragment = "";
|
||||
}
|
||||
@@ -461,7 +494,7 @@ namespace ts.Completions.StringCompletions {
|
||||
if (versionPaths) {
|
||||
const packageDirectory = getDirectoryPath(packageJsonPath);
|
||||
const pathInPackage = absolutePath.slice(ensureTrailingDirectorySeparator(packageDirectory).length);
|
||||
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) {
|
||||
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
|
||||
// A true result means one of the `versionPaths` was matched, which will block relative resolution
|
||||
// to files and folders from here. All reachable paths given the pattern match are already added.
|
||||
return result;
|
||||
@@ -474,41 +507,18 @@ namespace ts.Completions.StringCompletions {
|
||||
if (!tryDirectoryExists(host, baseDirectory)) return result;
|
||||
|
||||
// Enumerate the available files if possible
|
||||
const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
|
||||
const files = tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
|
||||
|
||||
if (files) {
|
||||
/**
|
||||
* Multiple file entries might map to the same truncated name once we remove extensions
|
||||
* (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg:
|
||||
*
|
||||
* both foo.ts and foo.tsx become foo
|
||||
*/
|
||||
const foundFiles = new Map<string, Extension | undefined>(); // maps file to its extension
|
||||
for (let filePath of files) {
|
||||
filePath = normalizePath(filePath);
|
||||
if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let foundFileName: string;
|
||||
const outputExtension = moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings());
|
||||
if (includeExtensionsOption === IncludeExtensionsOption.Exclude && !fileExtensionIsOneOf(filePath, [Extension.Json, Extension.Mts, Extension.Cts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Cjs])) {
|
||||
foundFileName = removeFileExtension(getBaseFileName(filePath));
|
||||
foundFiles.set(foundFileName, tryGetExtensionFromPath(filePath));
|
||||
}
|
||||
else if ((fileExtensionIsOneOf(filePath, [Extension.Mts, Extension.Cts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Cjs]) || includeExtensionsOption === IncludeExtensionsOption.ModuleSpecifierCompletion) && outputExtension) {
|
||||
foundFileName = changeExtension(getBaseFileName(filePath), outputExtension);
|
||||
foundFiles.set(foundFileName, outputExtension);
|
||||
}
|
||||
else {
|
||||
foundFileName = getBaseFileName(filePath);
|
||||
foundFiles.set(foundFileName, tryGetExtensionFromPath(filePath));
|
||||
}
|
||||
const { name, extension } = getFilenameWithExtensionOption(getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption);
|
||||
result.add(nameAndKind(name, ScriptElementKind.scriptElement, extension));
|
||||
}
|
||||
|
||||
foundFiles.forEach((ext, foundFile) => {
|
||||
result.push(nameAndKind(foundFile, ScriptElementKind.scriptElement, ext));
|
||||
});
|
||||
}
|
||||
|
||||
// If possible, get folder completion as well
|
||||
@@ -518,7 +528,7 @@ namespace ts.Completions.StringCompletions {
|
||||
for (const directory of directories) {
|
||||
const directoryName = getBaseFileName(normalizePath(directory));
|
||||
if (directoryName !== "@types") {
|
||||
result.push(directoryResult(directoryName));
|
||||
result.add(directoryResult(directoryName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -526,18 +536,61 @@ namespace ts.Completions.StringCompletions {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getFilenameWithExtensionOption(name: string, compilerOptions: CompilerOptions, includeExtensionsOption: IncludeExtensionsOption): { name: string, extension: Extension | undefined } {
|
||||
const outputExtension = moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions);
|
||||
if (includeExtensionsOption === IncludeExtensionsOption.Exclude && !fileExtensionIsOneOf(name, [Extension.Json, Extension.Mts, Extension.Cts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Cjs])) {
|
||||
return { name: removeFileExtension(name), extension: tryGetExtensionFromPath(name) };
|
||||
}
|
||||
else if ((fileExtensionIsOneOf(name, [Extension.Mts, Extension.Cts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Cjs]) || includeExtensionsOption === IncludeExtensionsOption.ModuleSpecifierCompletion) && outputExtension) {
|
||||
return { name: changeExtension(name, outputExtension), extension: outputExtension };
|
||||
}
|
||||
else {
|
||||
return { name, extension: tryGetExtensionFromPath(name) };
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
|
||||
function addCompletionEntriesFromPaths(result: NameAndKind[], fragment: string, baseDirectory: string, fileExtensions: readonly string[], paths: MapLike<string[]>, host: LanguageServiceHost) {
|
||||
function addCompletionEntriesFromPaths(
|
||||
result: NameAndKindSet,
|
||||
fragment: string,
|
||||
baseDirectory: string,
|
||||
extensionOptions: ExtensionOptions,
|
||||
host: LanguageServiceHost,
|
||||
paths: MapLike<string[]>
|
||||
) {
|
||||
const getPatternsForKey = (key: string) => paths[key];
|
||||
const comparePaths = (a: string, b: string): Comparison => {
|
||||
const patternA = tryParsePattern(a);
|
||||
const patternB = tryParsePattern(b);
|
||||
const lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length;
|
||||
const lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length;
|
||||
return compareValues(lengthB, lengthA);
|
||||
};
|
||||
return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, getOwnKeys(paths), getPatternsForKey, comparePaths);
|
||||
}
|
||||
|
||||
/** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
|
||||
function addCompletionEntriesFromPathsOrExports(
|
||||
result: NameAndKindSet,
|
||||
fragment: string,
|
||||
baseDirectory: string,
|
||||
extensionOptions: ExtensionOptions,
|
||||
host: LanguageServiceHost,
|
||||
keys: readonly string[],
|
||||
getPatternsForKey: (key: string) => string[] | undefined,
|
||||
comparePaths: (a: string, b: string) => Comparison,
|
||||
) {
|
||||
let pathResults: { results: NameAndKind[], matchedPattern: boolean }[] = [];
|
||||
let matchedPathPrefixLength = -1;
|
||||
for (const path in paths) {
|
||||
if (!hasProperty(paths, path)) continue;
|
||||
const patterns = paths[path];
|
||||
let matchedPath: string | undefined;
|
||||
for (const key of keys) {
|
||||
if (key === ".") continue;
|
||||
const keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./"
|
||||
const patterns = getPatternsForKey(key);
|
||||
if (patterns) {
|
||||
const pathPattern = tryParsePattern(path);
|
||||
const pathPattern = tryParsePattern(keyWithoutLeadingDotSlash);
|
||||
if (!pathPattern) continue;
|
||||
const isMatch = typeof pathPattern === "object" && isPatternMatch(pathPattern, fragment);
|
||||
const isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength);
|
||||
const isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === Comparison.LessThan);
|
||||
if (isLongestMatch) {
|
||||
// If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
|
||||
// for `import {} from "some-package/|"` with a typesVersions:
|
||||
@@ -550,24 +603,21 @@ namespace ts.Completions.StringCompletions {
|
||||
// added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
|
||||
// ./dist/foo and ./foo, when only the latter will actually be resolvable.
|
||||
// See pathCompletionsTypesVersionsWildcard6.ts.
|
||||
matchedPathPrefixLength = pathPattern.prefix.length;
|
||||
matchedPath = key;
|
||||
pathResults = pathResults.filter(r => !r.matchedPattern);
|
||||
}
|
||||
if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) {
|
||||
if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== Comparison.GreaterThan) {
|
||||
pathResults.push({
|
||||
matchedPattern: isMatch,
|
||||
results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host)
|
||||
results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host)
|
||||
.map(({ name, kind, extension }) => nameAndKind(name, kind, extension)),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const equatePaths = host.useCaseSensitiveFileNames?.() ? equateStringsCaseSensitive : equateStringsCaseInsensitive;
|
||||
const equateResults: EqualityComparer<NameAndKind> = (a, b) => equatePaths(a.name, b.name);
|
||||
pathResults.forEach(pathResult => pathResult.results.forEach(pathResult => pushIfUnique(result, pathResult, equateResults)));
|
||||
|
||||
return matchedPathPrefixLength > -1;
|
||||
pathResults.forEach(pathResult => pathResult.results.forEach(r => result.add(r)));
|
||||
return matchedPath !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -577,24 +627,31 @@ namespace ts.Completions.StringCompletions {
|
||||
* Modules from node_modules (i.e. those listed in package.json)
|
||||
* This includes all files that are found in node_modules/moduleName/ with acceptable file extensions
|
||||
*/
|
||||
function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): readonly NameAndKind[] {
|
||||
function getCompletionEntriesForNonRelativeModules(
|
||||
fragment: string,
|
||||
scriptPath: string,
|
||||
mode: SourceFile["impliedNodeFormat"],
|
||||
compilerOptions: CompilerOptions,
|
||||
host: LanguageServiceHost,
|
||||
includeExtensionsOption: IncludeExtensionsOption,
|
||||
typeChecker: TypeChecker,
|
||||
): readonly NameAndKind[] {
|
||||
const { baseUrl, paths } = compilerOptions;
|
||||
|
||||
const result: NameAndKind[] = [];
|
||||
|
||||
const extensionOptions = getExtensionOptions(compilerOptions);
|
||||
const result = createNameAndKindSet();
|
||||
const extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption);
|
||||
if (baseUrl) {
|
||||
const projectDir = compilerOptions.project || host.getCurrentDirectory();
|
||||
const absolute = normalizePath(combinePaths(projectDir, baseUrl));
|
||||
getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result);
|
||||
if (paths) {
|
||||
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host);
|
||||
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
|
||||
}
|
||||
}
|
||||
|
||||
const fragmentDirectory = getFragmentDirectory(fragment);
|
||||
for (const ambientName of getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker)) {
|
||||
result.push(nameAndKind(ambientName, ScriptElementKind.externalModuleName, /*extension*/ undefined));
|
||||
result.add(nameAndKind(ambientName, ScriptElementKind.externalModuleName, /*extension*/ undefined));
|
||||
}
|
||||
|
||||
getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
|
||||
@@ -605,9 +662,10 @@ namespace ts.Completions.StringCompletions {
|
||||
let foundGlobal = false;
|
||||
if (fragmentDirectory === undefined) {
|
||||
for (const moduleName of enumerateNodeModulesVisibleToScript(host, scriptPath)) {
|
||||
if (!result.some(entry => entry.name === moduleName)) {
|
||||
const moduleResult = nameAndKind(moduleName, ScriptElementKind.externalModuleName, /*extension*/ undefined);
|
||||
if (!result.has(moduleResult.name)) {
|
||||
foundGlobal = true;
|
||||
result.push(nameAndKind(moduleName, ScriptElementKind.externalModuleName, /*extension*/ undefined));
|
||||
result.add(moduleResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -634,36 +692,27 @@ namespace ts.Completions.StringCompletions {
|
||||
}
|
||||
packagePath = combinePaths(packagePath, subName);
|
||||
}
|
||||
const packageFile = combinePaths(ancestor, "node_modules", packagePath, "package.json");
|
||||
const packageDirectory = combinePaths(ancestor, "node_modules", packagePath);
|
||||
const packageFile = combinePaths(packageDirectory, "package.json");
|
||||
if (tryFileExists(host, packageFile)) {
|
||||
const packageJson = readJson(packageFile, host as { readFile: (filename: string) => string | undefined });
|
||||
const packageJson = readJson(packageFile, host);
|
||||
const exports = (packageJson as any).exports;
|
||||
if (exports) {
|
||||
if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
|
||||
return; // null exports or entrypoint only, no sub-modules available
|
||||
}
|
||||
const keys = getOwnKeys(exports);
|
||||
const fragmentSubpath = components.join("/");
|
||||
const processedKeys = mapDefined(keys, k => {
|
||||
if (k === ".") return undefined;
|
||||
if (!startsWith(k, "./")) return undefined;
|
||||
const subpath = k.substring(2);
|
||||
if (!startsWith(subpath, fragmentSubpath)) return undefined;
|
||||
// subpath is a valid export (barring conditions, which we don't currently check here)
|
||||
if (!stringContains(subpath, "*")) {
|
||||
return subpath;
|
||||
}
|
||||
// pattern export - only return everything up to the `*`, so the user can autocomplete, then
|
||||
// keep filling in the pattern (we could speculatively return a list of options by hitting disk,
|
||||
// but conditions will make that somewhat awkward, as each condition may have a different set of possible
|
||||
// options for the `*`.
|
||||
return subpath.slice(0, subpath.indexOf("*"));
|
||||
});
|
||||
forEach(processedKeys, k => {
|
||||
if (k) {
|
||||
result.push(nameAndKind(k, ScriptElementKind.externalModuleName, /*extension*/ undefined));
|
||||
}
|
||||
});
|
||||
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
||||
const conditions = mode === ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"];
|
||||
addCompletionEntriesFromPathsOrExports(
|
||||
result,
|
||||
fragmentSubpath,
|
||||
packageDirectory,
|
||||
extensionOptions,
|
||||
host,
|
||||
keys,
|
||||
key => singleElementArray(getPatternFromFirstMatchingCondition(exports[key], conditions)),
|
||||
comparePatternKeys);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -674,7 +723,21 @@ namespace ts.Completions.StringCompletions {
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return arrayFrom(result.values());
|
||||
}
|
||||
|
||||
function getPatternFromFirstMatchingCondition(target: unknown, conditions: readonly string[]): string | undefined {
|
||||
if (typeof target === "string") {
|
||||
return target;
|
||||
}
|
||||
if (target && typeof target === "object" && !isArray(target)) {
|
||||
for (const condition in target) {
|
||||
if (condition === "default" || conditions.indexOf(condition) > -1 || isApplicableVersionedTypesKey(conditions, condition)) {
|
||||
const pattern = (target as MapLike<unknown>)[condition];
|
||||
return getPatternFromFirstMatchingCondition(pattern, conditions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getFragmentDirectory(fragment: string): string | undefined {
|
||||
@@ -682,28 +745,39 @@ namespace ts.Completions.StringCompletions {
|
||||
}
|
||||
|
||||
function getCompletionsForPathMapping(
|
||||
path: string, patterns: readonly string[], fragment: string, baseUrl: string, fileExtensions: readonly string[], host: LanguageServiceHost,
|
||||
path: string,
|
||||
patterns: readonly string[],
|
||||
fragment: string,
|
||||
packageDirectory: string,
|
||||
extensionOptions: ExtensionOptions,
|
||||
host: LanguageServiceHost,
|
||||
): readonly NameAndKind[] {
|
||||
if (!endsWith(path, "*")) {
|
||||
// For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion.
|
||||
return !stringContains(path, "*") ? justPathMappingName(path) : emptyArray;
|
||||
return !stringContains(path, "*") ? justPathMappingName(path, ScriptElementKind.scriptElement) : emptyArray;
|
||||
}
|
||||
|
||||
const pathPrefix = path.slice(0, path.length - 1);
|
||||
const remainingFragment = tryRemovePrefix(fragment, pathPrefix);
|
||||
if (remainingFragment === undefined) {
|
||||
const starIsFullPathComponent = path[path.length - 2] === "/";
|
||||
return starIsFullPathComponent ? justPathMappingName(pathPrefix) : flatMap(patterns, pattern =>
|
||||
getModulesForPathsPattern("", baseUrl, pattern, fileExtensions, host)?.map(({ name, ...rest }) => ({ name: pathPrefix + name, ...rest })));
|
||||
return starIsFullPathComponent ? justPathMappingName(pathPrefix, ScriptElementKind.directory) : flatMap(patterns, pattern =>
|
||||
getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, host)?.map(({ name, ...rest }) => ({ name: pathPrefix + name, ...rest })));
|
||||
}
|
||||
return flatMap(patterns, pattern => getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host));
|
||||
return flatMap(patterns, pattern => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host));
|
||||
|
||||
function justPathMappingName(name: string): readonly NameAndKind[] {
|
||||
return startsWith(name, fragment) ? [directoryResult(removeTrailingDirectorySeparator(name))] : emptyArray;
|
||||
function justPathMappingName(name: string, kind: ScriptElementKind.directory | ScriptElementKind.scriptElement): readonly NameAndKind[] {
|
||||
return startsWith(name, fragment) ? [{ name: removeTrailingDirectorySeparator(name), kind, extension: undefined }] : emptyArray;
|
||||
}
|
||||
}
|
||||
|
||||
function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: readonly string[], host: LanguageServiceHost): readonly NameAndKind[] | undefined {
|
||||
function getModulesForPathsPattern(
|
||||
fragment: string,
|
||||
packageDirectory: string,
|
||||
pattern: string,
|
||||
extensionOptions: ExtensionOptions,
|
||||
host: LanguageServiceHost,
|
||||
): readonly NameAndKind[] | undefined {
|
||||
if (!host.readDirectory) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -727,23 +801,36 @@ namespace ts.Completions.StringCompletions {
|
||||
|
||||
const normalizedSuffix = normalizePath(parsed.suffix);
|
||||
// Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b".
|
||||
const baseDirectory = normalizePath(combinePaths(baseUrl, expandedPrefixDirectory));
|
||||
const baseDirectory = normalizePath(combinePaths(packageDirectory, expandedPrefixDirectory));
|
||||
const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase;
|
||||
|
||||
// If we have a suffix, then we need to read the directory all the way down. We could create a glob
|
||||
// that encodes the suffix, but we would have to escape the character "?" which readDirectory
|
||||
// doesn't support. For now, this is safer but slower
|
||||
const includeGlob = normalizedSuffix ? "**/*" : "./*";
|
||||
// If we have a suffix, then we read the directory all the way down to avoid returning completions for
|
||||
// directories that don't contain files that would match the suffix. A previous comment here was concerned
|
||||
// about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally,
|
||||
// but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not
|
||||
// a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?`
|
||||
// interpreted as "any character" can only return *too many* results as compared to the literal
|
||||
// interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always
|
||||
// done.
|
||||
const includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*";
|
||||
|
||||
const matches = mapDefined(tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), match => {
|
||||
const extension = tryGetExtensionFromPath(match);
|
||||
const name = trimPrefixAndSuffix(match);
|
||||
return name === undefined ? undefined : nameAndKind(removeFileExtension(name), ScriptElementKind.scriptElement, extension);
|
||||
});
|
||||
const directories = mapDefined(tryGetDirectories(host, baseDirectory).map(d => combinePaths(baseDirectory, d)), dir => {
|
||||
const name = trimPrefixAndSuffix(dir);
|
||||
return name === undefined ? undefined : directoryResult(name);
|
||||
const matches = mapDefined(tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), match => {
|
||||
const trimmedWithPattern = trimPrefixAndSuffix(match);
|
||||
if (trimmedWithPattern) {
|
||||
if (containsSlash(trimmedWithPattern)) {
|
||||
return directoryResult(getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
|
||||
}
|
||||
const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption);
|
||||
return nameAndKind(name, ScriptElementKind.scriptElement, extension);
|
||||
}
|
||||
});
|
||||
|
||||
// If we had a suffix, we already recursively searched for all possible files that could match
|
||||
// it and returned the directories leading to those files. Otherwise, assume any directory could
|
||||
// have something valid to import.
|
||||
const directories = normalizedSuffix
|
||||
? emptyArray
|
||||
: mapDefined(tryGetDirectories(host, baseDirectory), dir => dir === "node_modules" ? undefined : directoryResult(dir));
|
||||
return [...matches, ...directories];
|
||||
|
||||
function trimPrefixAndSuffix(path: string): string | undefined {
|
||||
@@ -793,10 +880,10 @@ namespace ts.Completions.StringCompletions {
|
||||
const names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, IncludeExtensionsOption.Include), host, sourceFile.path)
|
||||
: kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions))
|
||||
: Debug.fail();
|
||||
return addReplacementSpans(toComplete, range.pos + prefix.length, names);
|
||||
return addReplacementSpans(toComplete, range.pos + prefix.length, arrayFrom(names.values()));
|
||||
}
|
||||
|
||||
function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, fragmentDirectory: string | undefined, extensionOptions: ExtensionOptions, result: NameAndKind[] = []): readonly NameAndKind[] {
|
||||
function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, fragmentDirectory: string | undefined, extensionOptions: ExtensionOptions, result = createNameAndKindSet()): NameAndKindSet {
|
||||
// Check for typings specified in compiler options
|
||||
const seen = new Map<string, true>();
|
||||
|
||||
@@ -823,7 +910,7 @@ namespace ts.Completions.StringCompletions {
|
||||
|
||||
if (fragmentDirectory === undefined) {
|
||||
if (!seen.has(packageName)) {
|
||||
result.push(nameAndKind(packageName, ScriptElementKind.externalModuleName, /*extension*/ undefined));
|
||||
result.add(nameAndKind(packageName, ScriptElementKind.externalModuleName, /*extension*/ undefined));
|
||||
seen.set(packageName, true);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-4
@@ -197,7 +197,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface PackageJsonInfo {
|
||||
export interface ProjectPackageJsonInfo {
|
||||
fileName: string;
|
||||
parseable: boolean;
|
||||
dependencies?: ESMap<string, string>;
|
||||
@@ -311,9 +311,9 @@ namespace ts {
|
||||
|
||||
/* @internal */ getDocumentPositionMapper?(generatedFileName: string, sourceFileName?: string): DocumentPositionMapper | undefined;
|
||||
/* @internal */ getSourceFileLike?(fileName: string): SourceFileLike | undefined;
|
||||
/* @internal */ getPackageJsonsVisibleToFile?(fileName: string, rootDir?: string): readonly PackageJsonInfo[];
|
||||
/* @internal */ getPackageJsonsVisibleToFile?(fileName: string, rootDir?: string): readonly ProjectPackageJsonInfo[];
|
||||
/* @internal */ getNearestAncestorDirectoryWithPackageJson?(fileName: string): string | undefined;
|
||||
/* @internal */ getPackageJsonsForAutoImport?(rootDir?: string): readonly PackageJsonInfo[];
|
||||
/* @internal */ getPackageJsonsForAutoImport?(rootDir?: string): readonly ProjectPackageJsonInfo[];
|
||||
/* @internal */ getCachedExportInfoMap?(): ExportInfoMap;
|
||||
/* @internal */ getModuleSpecifierCache?(): ModuleSpecifierCache;
|
||||
/* @internal */ setCompilerHost?(host: CompilerHost): void;
|
||||
@@ -551,6 +551,7 @@ namespace ts {
|
||||
getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput;
|
||||
|
||||
getProgram(): Program | undefined;
|
||||
/*@internal*/ getCurrentProgram(): Program | undefined;
|
||||
|
||||
/* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
|
||||
/* @internal */ getAutoImportProvider(): Program | undefined;
|
||||
@@ -1045,7 +1046,12 @@ namespace ts {
|
||||
containerKind: ScriptElementKind;
|
||||
containerName: string;
|
||||
unverified?: boolean;
|
||||
/* @internal */ isLocal?: boolean;
|
||||
/** @internal
|
||||
* Initially, this value is determined syntactically, but it is updated by the checker to cover
|
||||
* cases like declarations that are exported in subsequent statements. As a result, the value
|
||||
* may be "incomplete" if this span has yet to be checked.
|
||||
*/
|
||||
isLocal?: boolean;
|
||||
/* @internal */ isAmbient?: boolean;
|
||||
/* @internal */ failedAliasResolution?: boolean;
|
||||
}
|
||||
|
||||
@@ -1147,13 +1147,20 @@ namespace ts {
|
||||
// position and whose end is greater than the position.
|
||||
|
||||
|
||||
// There are more sophisticated end tests later, but this one is very fast
|
||||
// and allows us to skip a bunch of work
|
||||
const end = children[middle].getEnd();
|
||||
if (end < position) {
|
||||
return Comparison.LessThan;
|
||||
}
|
||||
|
||||
const start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true);
|
||||
if (start > position) {
|
||||
return Comparison.GreaterThan;
|
||||
}
|
||||
|
||||
// first element whose start position is before the input and whose end position is after or equal to the input
|
||||
if (nodeContainsPosition(children[middle])) {
|
||||
if (nodeContainsPosition(children[middle], start, end)) {
|
||||
if (children[middle - 1]) {
|
||||
// we want the _first_ element that contains the position, so left-recur if the prior node also contains the position
|
||||
if (nodeContainsPosition(children[middle - 1])) {
|
||||
@@ -1181,13 +1188,16 @@ namespace ts {
|
||||
return current;
|
||||
}
|
||||
|
||||
function nodeContainsPosition(node: Node) {
|
||||
const start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true);
|
||||
function nodeContainsPosition(node: Node, start?: number, end?: number) {
|
||||
end ??= node.getEnd();
|
||||
if (end < position) {
|
||||
return false;
|
||||
}
|
||||
start ??= allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true);
|
||||
if (start > position) {
|
||||
// If this child begins after position, then all subsequent children will as well.
|
||||
return false;
|
||||
}
|
||||
const end = node.getEnd();
|
||||
if (position < end || (position === end && (node.kind === SyntaxKind.EndOfFileToken || includeEndPosition))) {
|
||||
return true;
|
||||
}
|
||||
@@ -2647,7 +2657,7 @@ namespace ts {
|
||||
Debug.assert(fileName === renameFilename);
|
||||
for (const change of textChanges) {
|
||||
const { span, newText } = change;
|
||||
const index = indexInTextChange(newText, name);
|
||||
const index = indexInTextChange(newText, escapeString(name));
|
||||
if (index !== -1) {
|
||||
lastPos = span.start + delta + index;
|
||||
|
||||
@@ -2994,12 +3004,12 @@ namespace ts {
|
||||
return packageJson;
|
||||
}
|
||||
|
||||
export function getPackageJsonsVisibleToFile(fileName: string, host: LanguageServiceHost): readonly PackageJsonInfo[] {
|
||||
export function getPackageJsonsVisibleToFile(fileName: string, host: LanguageServiceHost): readonly ProjectPackageJsonInfo[] {
|
||||
if (!host.fileExists) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const packageJsons: PackageJsonInfo[] = [];
|
||||
const packageJsons: ProjectPackageJsonInfo[] = [];
|
||||
forEachAncestorDirectory(getDirectoryPath(fileName), ancestor => {
|
||||
const packageJsonFileName = combinePaths(ancestor, "package.json");
|
||||
if (host.fileExists(packageJsonFileName)) {
|
||||
@@ -3013,7 +3023,7 @@ namespace ts {
|
||||
return packageJsons;
|
||||
}
|
||||
|
||||
export function createPackageJsonInfo(fileName: string, host: { readFile?(fileName: string): string | undefined }): PackageJsonInfo | undefined {
|
||||
export function createPackageJsonInfo(fileName: string, host: { readFile?(fileName: string): string | undefined }): ProjectPackageJsonInfo | undefined {
|
||||
if (!host.readFile) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -3022,7 +3032,7 @@ namespace ts {
|
||||
const dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"] as const;
|
||||
const stringContent = host.readFile(fileName) || "";
|
||||
const content = tryParseJson(stringContent) as PackageJsonRaw | undefined;
|
||||
const info: Pick<PackageJsonInfo, typeof dependencyKeys[number]> = {};
|
||||
const info: Pick<ProjectPackageJsonInfo, typeof dependencyKeys[number]> = {};
|
||||
if (content) {
|
||||
for (const key of dependencyKeys) {
|
||||
const dependencies = content[key];
|
||||
|
||||
@@ -141,7 +141,8 @@ namespace Harness {
|
||||
"preserveConstEnums",
|
||||
"skipLibCheck",
|
||||
"exactOptionalPropertyTypes",
|
||||
"useUnknownInCatchVariables"
|
||||
"useDefineForClassFields",
|
||||
"useUnknownInCatchVariables",
|
||||
];
|
||||
private fileName: string;
|
||||
private justName: string;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Harness {
|
||||
|
||||
abstract class ExternalCompileRunnerBase extends RunnerBase {
|
||||
abstract testDir: string;
|
||||
abstract report(result: ExecResult, cwd: string): string | null;
|
||||
abstract report(result: ExecResult): string | null;
|
||||
enumerateTestFiles() {
|
||||
return IO.getDirectories(this.testDir);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
args.push("--noEmit");
|
||||
Baseline.runBaseline(`${cls.kind()}/${directoryName}.log`, cls.report(cp.spawnSync(`node`, args, { cwd, timeout, shell: true }), cwd));
|
||||
Baseline.runBaseline(`${cls.kind()}/${directoryName}.log`, cls.report(cp.spawnSync(`node`, args, { cwd, timeout, shell: true })));
|
||||
|
||||
function exec(command: string, args: string[], options: { cwd: string, timeout?: number, stdio?: import("child_process").StdioOptions }): string | undefined {
|
||||
const res = cp.spawnSync(isWorker ? `${command} 2>&1` : command, args, { shell: true, stdio, ...options });
|
||||
@@ -281,46 +281,18 @@ ${sanitizeDockerfileOutput(result.stderr.toString())}`;
|
||||
kind(): TestRunnerKind {
|
||||
return "dt";
|
||||
}
|
||||
report(result: ExecResult, cwd: string) {
|
||||
const stdout = removeExpectedErrors(result.stdout.toString(), cwd);
|
||||
const stderr = result.stderr.toString();
|
||||
|
||||
report(result: ExecResult) {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
return !stdout.length && !stderr.length ? null : `Exit Code: ${result.status}
|
||||
return !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status}
|
||||
Standard output:
|
||||
${stdout.replace(/\r\n/g, "\n")}
|
||||
${result.stdout.toString().replace(/\r\n/g, "\n")}
|
||||
|
||||
|
||||
Standard error:
|
||||
${stderr.replace(/\r\n/g, "\n")}`;
|
||||
${result.stderr.toString().replace(/\r\n/g, "\n")}`;
|
||||
}
|
||||
}
|
||||
|
||||
function removeExpectedErrors(errors: string, cwd: string): string {
|
||||
return ts.flatten(splitBy(errors.split("\n"), s => /^\S+/.test(s)).filter(isUnexpectedError(cwd))).join("\n");
|
||||
}
|
||||
/**
|
||||
* Returns true if the line that caused the error contains '$ExpectError',
|
||||
* or if the line before that one contains '$ExpectError'.
|
||||
* '$ExpectError' is a marker used in Definitely Typed tests,
|
||||
* meaning that the error should not contribute toward our error baslines.
|
||||
*/
|
||||
function isUnexpectedError(cwd: string) {
|
||||
return (error: string[]) => {
|
||||
ts.Debug.assertGreaterThanOrEqual(error.length, 1);
|
||||
const match = error[0].match(/(.+\.tsx?)\((\d+),\d+\): error TS/);
|
||||
if (!match) {
|
||||
return true;
|
||||
}
|
||||
const [, errorFile, lineNumberString] = match;
|
||||
const lines = fs.readFileSync(path.join(cwd, errorFile), { encoding: "utf8" }).split("\n");
|
||||
const lineNumber = parseInt(lineNumberString) - 1;
|
||||
ts.Debug.assertGreaterThanOrEqual(lineNumber, 0);
|
||||
ts.Debug.assertLessThan(lineNumber, lines.length);
|
||||
const previousLine = lineNumber - 1 > 0 ? lines[lineNumber - 1] : "";
|
||||
return !ts.stringContains(lines[lineNumber], "$ExpectError") && !ts.stringContains(previousLine, "$ExpectError");
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Split an array into multiple arrays whenever `isStart` returns true.
|
||||
* @example
|
||||
|
||||
@@ -205,6 +205,7 @@
|
||||
"unittests/tsserver/languageService.ts",
|
||||
"unittests/tsserver/maxNodeModuleJsDepth.ts",
|
||||
"unittests/tsserver/metadataInResponse.ts",
|
||||
"unittests/tsserver/moduleResolution.ts",
|
||||
"unittests/tsserver/moduleSpecifierCache.ts",
|
||||
"unittests/tsserver/navTo.ts",
|
||||
"unittests/tsserver/occurences.ts",
|
||||
|
||||
@@ -62,7 +62,6 @@ export function Component(x: Config): any;`
|
||||
emitSkipped: true,
|
||||
diagnostics: emptyArray,
|
||||
outputFiles: emptyArray,
|
||||
exportedModulesFromDeclarationEmit: undefined
|
||||
}
|
||||
);
|
||||
|
||||
@@ -80,7 +79,6 @@ export function Component(x: Config): any;`
|
||||
text: "export {};\r\n",
|
||||
writeByteOrderMark: false
|
||||
}],
|
||||
exportedModulesFromDeclarationEmit: undefined
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@@ -485,5 +485,19 @@ export { a as alias };
|
||||
export * as alias from './file';`, {
|
||||
noSetFileName: true
|
||||
});
|
||||
|
||||
transpilesCorrectly("Elides import equals referenced only by export type",
|
||||
`import IFoo = Namespace.IFoo;` +
|
||||
`export type { IFoo };`, {
|
||||
options: { compilerOptions: { module: ModuleKind.CommonJS } }
|
||||
}
|
||||
);
|
||||
|
||||
transpilesCorrectly("Elides import equals referenced only by type only export specifier",
|
||||
`import IFoo = Namespace.IFoo;` +
|
||||
`export { type IFoo };`, {
|
||||
options: { compilerOptions: { module: ModuleKind.CommonJS } }
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ interface Symbol {
|
||||
toFileName(s) :
|
||||
[toFileName(s[0]), s[1]]
|
||||
),
|
||||
dtsChangeTime: buildInfo.program.dtsChangeTime,
|
||||
latestChangedDtsFile: buildInfo.program.latestChangedDtsFile,
|
||||
};
|
||||
}
|
||||
const version = buildInfo.version === ts.version ? fakes.version : buildInfo.version;
|
||||
@@ -544,7 +544,7 @@ interface Symbol {
|
||||
options: { ...readableBuildInfo.program.options, noEmit: undefined },
|
||||
exportedModulesMap: undefined,
|
||||
affectedFilesPendingEmit: undefined,
|
||||
dtsChangeTime: readableBuildInfo.program.dtsChangeTime ? "FakeTime" : undefined,
|
||||
latestChangedDtsFile: readableBuildInfo.program.latestChangedDtsFile ? "FakeFileName" : undefined,
|
||||
},
|
||||
size: undefined, // Size doesnt need to be equal
|
||||
}, /*replacer*/ undefined, 2),
|
||||
|
||||
@@ -125,8 +125,8 @@ const a: string = 10;`, "utf-8"),
|
||||
function verifyNoEmitChanges(compilerOptions: CompilerOptions) {
|
||||
const discrepancyExplanation = () => [
|
||||
...noChangeWithExportsDiscrepancyRun.discrepancyExplanation!(),
|
||||
"Clean build will not have dtsChangeTime as there was no emit and emitSignatures as undefined for files",
|
||||
"Incremental will store the past dtsChangeTime and emitSignatures",
|
||||
"Clean build will not have latestChangedDtsFile as there was no emit and emitSignatures as undefined for files",
|
||||
"Incremental will store the past latestChangedDtsFile and emitSignatures",
|
||||
];
|
||||
const discrepancyIfNoDtsEmit = getEmitDeclarations(compilerOptions) ?
|
||||
undefined :
|
||||
@@ -524,5 +524,46 @@ console.log(a);`,
|
||||
modifyFs: fs => fs.writeFileSync("/src/project/constants.ts", "export default 2;"),
|
||||
}],
|
||||
});
|
||||
|
||||
function verifyModifierChange(declaration: boolean) {
|
||||
verifyTscWithEdits({
|
||||
scenario: "incremental",
|
||||
subScenario: `change to modifier of class expression field${declaration ? " with declaration emit enabled" : ""}`,
|
||||
commandLineArgs: ["-p", "src/project", "--incremental"],
|
||||
fs: () => loadProjectFromFiles({
|
||||
"/src/project/tsconfig.json": JSON.stringify({ compilerOptions: { declaration } }),
|
||||
"/src/project/main.ts": Utils.dedent`
|
||||
import MessageablePerson from './MessageablePerson.js';
|
||||
function logMessage( person: MessageablePerson ) {
|
||||
console.log( person.message );
|
||||
}`,
|
||||
"/src/project/MessageablePerson.ts": Utils.dedent`
|
||||
const Messageable = () => {
|
||||
return class MessageableClass {
|
||||
public message = 'hello';
|
||||
}
|
||||
};
|
||||
const wrapper = () => Messageable();
|
||||
type MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;
|
||||
export default MessageablePerson;`,
|
||||
}),
|
||||
modifyFs: fs => appendText(fs, "/lib/lib.d.ts", Utils.dedent`
|
||||
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
|
||||
type InstanceType<T extends abstract new (...args: any) => any> = T extends abstract new (...args: any) => infer R ? R : any;`
|
||||
),
|
||||
edits: [
|
||||
{
|
||||
subScenario: "modify public to protected",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/MessageablePerson.ts", "public", "protected"),
|
||||
},
|
||||
{
|
||||
subScenario: "modify protected to public",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/MessageablePerson.ts", "protected", "public"),
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
verifyModifierChange(/*declaration*/ false);
|
||||
verifyModifierChange(/*declaration*/ true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,5 +72,189 @@ namespace ts.tscWatch {
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario: "moduleResolution",
|
||||
subScenario: "diagnostics from cache",
|
||||
sys: () => createWatchedSystem([
|
||||
{
|
||||
path: `${projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
moduleResolution: "nodenext",
|
||||
outDir: "./dist",
|
||||
declaration: true,
|
||||
declarationDir: "./types"
|
||||
},
|
||||
})
|
||||
},
|
||||
{
|
||||
path: `${projectRoot}/package.json`,
|
||||
content: JSON.stringify({
|
||||
name: "@this/package",
|
||||
type: "module",
|
||||
exports: {
|
||||
".": {
|
||||
default: "./dist/index.js",
|
||||
types: "./types/index.d.ts"
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
{
|
||||
path: `${projectRoot}/index.ts`,
|
||||
content: Utils.dedent`
|
||||
import * as me from "@this/package";
|
||||
me.thing()
|
||||
export function thing(): void {}
|
||||
`
|
||||
},
|
||||
libFile
|
||||
], { currentDirectory: projectRoot }),
|
||||
commandLineArgs: ["-w", "--traceResolution"],
|
||||
changes: emptyArray
|
||||
});
|
||||
|
||||
describe("package json file is edited", () => {
|
||||
function getSys(packageFileContents: string) {
|
||||
const configFile: File = {
|
||||
path: `${projectRoot}/src/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
target: "es2016",
|
||||
module: "Node16",
|
||||
outDir: "../out"
|
||||
}
|
||||
})
|
||||
};
|
||||
const packageFile: File = {
|
||||
path: `${projectRoot}/package.json`,
|
||||
content: packageFileContents
|
||||
};
|
||||
const fileA: File = {
|
||||
path: `${projectRoot}/src/fileA.ts`,
|
||||
content: Utils.dedent`
|
||||
import { foo } from "./fileB.mjs";
|
||||
foo();
|
||||
`
|
||||
};
|
||||
const fileB: File = {
|
||||
path: `${projectRoot}/project/src/fileB.mts`,
|
||||
content: Utils.dedent`
|
||||
export function foo() {
|
||||
}
|
||||
`
|
||||
};
|
||||
return createWatchedSystem(
|
||||
[configFile, fileA, fileB, packageFile, { ...libFile, path: "/a/lib/lib.es2016.full.d.ts" }],
|
||||
{ currentDirectory: projectRoot }
|
||||
);
|
||||
}
|
||||
verifyTscWatch({
|
||||
scenario: "moduleResolution",
|
||||
subScenario: "package json file is edited",
|
||||
commandLineArgs: ["--w", "--p", "src", "--extendedDiagnostics", "-traceResolution", "--explainFiles"],
|
||||
sys: () => getSys(JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
changes: [
|
||||
{
|
||||
caption: "Modify package json file to add type module",
|
||||
change: sys => sys.writeFile(`${projectRoot}/package.json`, JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
})),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
{
|
||||
caption: "Modify package.json file to remove type module",
|
||||
change: sys => sys.writeFile(`${projectRoot}/package.json`, JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
{
|
||||
caption: "Delete package.json",
|
||||
change: sys => sys.deleteFile(`${projectRoot}/package.json`),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
{
|
||||
caption: "Modify package json file to add type module",
|
||||
change: sys => sys.writeFile(`${projectRoot}/package.json`, JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
})),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
{
|
||||
caption: "Delete package.json",
|
||||
change: sys => sys.deleteFile(`${projectRoot}/package.json`),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario: "moduleResolution",
|
||||
subScenario: "package json file is edited when package json with type module exists",
|
||||
commandLineArgs: ["--w", "--p", "src", "--extendedDiagnostics", "-traceResolution", "--explainFiles"],
|
||||
sys: () => getSys(JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
})),
|
||||
changes: [
|
||||
{
|
||||
caption: "Modify package.json file to remove type module",
|
||||
change: sys => sys.writeFile(`${projectRoot}/package.json`, JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
{
|
||||
caption: "Modify package json file to add type module",
|
||||
change: sys => sys.writeFile(`${projectRoot}/package.json`, JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
})),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
{
|
||||
caption: "Delete package.json",
|
||||
change: sys => sys.deleteFile(`${projectRoot}/package.json`),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
{
|
||||
caption: "Modify package json file to without type module",
|
||||
change: sys => sys.writeFile(`${projectRoot}/package.json`, JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
{
|
||||
caption: "Delete package.json",
|
||||
change: sys => sys.deleteFile(`${projectRoot}/package.json`),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace ts.tscWatch {
|
||||
},
|
||||
// not ideal, but currently because of d.ts but no new file is written
|
||||
// There will be timeout queued even though file contents are same
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
{
|
||||
caption: "non local edit in logic ts, and build logic",
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
namespace ts.projectSystem {
|
||||
describe("unittests:: tsserver:: moduleResolution", () => {
|
||||
describe("package json file is edited", () => {
|
||||
function setup(packageFileContents: string) {
|
||||
const configFile: File = {
|
||||
path: `${tscWatch.projectRoot}/src/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
target: "es2016",
|
||||
module: "Node16",
|
||||
outDir: "../out",
|
||||
traceResolution: true,
|
||||
}
|
||||
})
|
||||
};
|
||||
const packageFile: File = {
|
||||
path: `${tscWatch.projectRoot}/package.json`,
|
||||
content: packageFileContents
|
||||
};
|
||||
const fileA: File = {
|
||||
path: `${tscWatch.projectRoot}/src/fileA.ts`,
|
||||
content: Utils.dedent`
|
||||
import { foo } from "./fileB.mjs";
|
||||
foo();
|
||||
`
|
||||
};
|
||||
const fileB: File = {
|
||||
path: `${tscWatch.projectRoot}/src/fileB.mts`,
|
||||
content: Utils.dedent`
|
||||
export function foo() {
|
||||
}
|
||||
`
|
||||
};
|
||||
const host = createServerHost([configFile, fileA, fileB, packageFile, { ...libFile, path: "/a/lib/lib.es2016.full.d.ts" }]);
|
||||
const session = createSession(host, { canUseEvents: true, logger: createLoggerWithInMemoryLogs() });
|
||||
openFilesForSession([fileA], session);
|
||||
return {
|
||||
host, session, packageFile,
|
||||
verifyErr: () => verifyGetErrRequest({ files: [fileA], session, host }),
|
||||
};
|
||||
}
|
||||
it("package json file is edited", () => {
|
||||
const { host, session, packageFile, verifyErr } = setup(JSON.stringify({ name: "app", version: "1.0.0" }));
|
||||
|
||||
session.logger.info("Modify package json file to add type module");
|
||||
host.writeFile(packageFile.path, JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
}));
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
session.logger.info("Modify package json file to remove type module");
|
||||
host.writeFile(packageFile.path, packageFile.content);
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
session.logger.info("Delete package.json");
|
||||
host.deleteFile(packageFile.path);
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
session.logger.info("Modify package json file to add type module");
|
||||
host.writeFile(packageFile.path, JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
}));
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
session.logger.info("Delete package.json");
|
||||
host.deleteFile(packageFile.path);
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
baselineTsserverLogs("moduleResolution", "package json file is edited", session);
|
||||
});
|
||||
|
||||
it("package json file is edited when package json with type module exists", () => {
|
||||
const { host, session, packageFile, verifyErr } = setup(JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
}));
|
||||
|
||||
session.logger.info("Modify package json file to remove type module");
|
||||
host.writeFile(packageFile.path, JSON.stringify({ name: "app", version: "1.0.0" }));
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
session.logger.info("Modify package json file to add type module");
|
||||
host.writeFile(packageFile.path, packageFile.content);
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
session.logger.info("Delete package.json");
|
||||
host.deleteFile(packageFile.path);
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
session.logger.info("Modify package json file to without type module");
|
||||
host.writeFile(packageFile.path, JSON.stringify({ name: "app", version: "1.0.0" }));
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
session.logger.info("Delete package.json");
|
||||
host.deleteFile(packageFile.path);
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
baselineTsserverLogs("moduleResolution", "package json file is edited when package json with type module exists", session);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -139,7 +139,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -175,7 +175,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -218,7 +218,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -261,7 +261,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -315,7 +315,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -369,7 +369,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -412,7 +412,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -455,7 +455,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -509,7 +509,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -563,7 +563,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -597,7 +597,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -628,7 +628,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -666,7 +666,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -704,7 +704,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -753,7 +753,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -802,7 +802,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -840,7 +840,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -878,7 +878,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -927,7 +927,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -976,7 +976,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1017,7 +1017,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1053,7 +1053,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1107,7 +1107,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1161,7 +1161,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1215,7 +1215,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1269,7 +1269,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1323,7 +1323,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1377,7 +1377,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1431,7 +1431,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1485,7 +1485,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: usageTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1519,7 +1519,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1568,7 +1568,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1617,7 +1617,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1666,7 +1666,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1715,7 +1715,7 @@ ${appendDts}`
|
||||
assert.equal(host.writtenFiles.size, 0);
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: usageConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1755,7 +1755,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1791,7 +1791,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: dependencyConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1846,7 +1846,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1900,7 +1900,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: dependencyConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -1955,7 +1955,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -2009,7 +2009,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: dependencyConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -2064,7 +2064,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -2118,7 +2118,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: dependencyConfig.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -2173,7 +2173,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path }
|
||||
}).response as EmitOutput;
|
||||
@@ -2227,7 +2227,7 @@ ${appendDts}`
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
const actualEmitOutput = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: { file: dependencyTs.path, projectFileName: dependencyConfig.path }
|
||||
}).response as EmitOutput;
|
||||
|
||||
@@ -131,6 +131,16 @@ new C();`
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
|
||||
verifyGetErrRequest({ session, host, files: [recognizersDateTimeSrcFile] });
|
||||
|
||||
// Change config file's module resolution affecting option
|
||||
const config = JSON.parse(host.readFile(recognizerDateTimeTsconfigPath)!);
|
||||
host.writeFile(recognizerDateTimeTsconfigPath, JSON.stringify({
|
||||
...config,
|
||||
compilerOptions: { ...config.compilerOptions, resolveJsonModule: true }
|
||||
}));
|
||||
host.runQueuedTimeoutCallbacks(); // Scheduled invalidation of resolutions
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
|
||||
baselineTsserverLogs("symLinks", `module resolution${withPathMapping ? " with path mapping" : ""} when project compiles from sources`, session);
|
||||
});
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace ts.server {
|
||||
}
|
||||
};
|
||||
|
||||
const pending: Buffer[] = [];
|
||||
const pending = createQueue<Buffer>();
|
||||
let canWrite = true;
|
||||
|
||||
if (useWatchGuard) {
|
||||
@@ -334,7 +334,7 @@ namespace ts.server {
|
||||
|
||||
function writeMessage(buf: Buffer) {
|
||||
if (!canWrite) {
|
||||
pending.push(buf);
|
||||
pending.enqueue(buf);
|
||||
}
|
||||
else {
|
||||
canWrite = false;
|
||||
@@ -344,8 +344,8 @@ namespace ts.server {
|
||||
|
||||
function setCanWriteFlagAndWriteMessageIfNecessary() {
|
||||
canWrite = true;
|
||||
if (pending.length) {
|
||||
writeMessage(pending.shift()!);
|
||||
if (!pending.isEmpty()) {
|
||||
writeMessage(pending.dequeue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ namespace ts.server {
|
||||
private installer!: NodeChildProcess;
|
||||
private projectService!: ProjectService;
|
||||
private activeRequestCount = 0;
|
||||
private requestQueue: QueuedOperation[] = [];
|
||||
private requestQueue = createQueue<QueuedOperation>();
|
||||
private requestMap = new Map<string, QueuedOperation>(); // Maps operation ID to newest requestQueue entry with that ID
|
||||
/** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */
|
||||
private requestedRegistry = false;
|
||||
@@ -567,7 +567,7 @@ namespace ts.server {
|
||||
if (this.logger.hasLevel(LogLevel.verbose)) {
|
||||
this.logger.info(`Deferring request for: ${operationId}`);
|
||||
}
|
||||
this.requestQueue.push(queuedRequest);
|
||||
this.requestQueue.enqueue(queuedRequest);
|
||||
this.requestMap.set(operationId, queuedRequest);
|
||||
}
|
||||
}
|
||||
@@ -649,8 +649,8 @@ namespace ts.server {
|
||||
Debug.fail("Received too many responses");
|
||||
}
|
||||
|
||||
while (this.requestQueue.length > 0) {
|
||||
const queuedRequest = this.requestQueue.shift()!;
|
||||
while (!this.requestQueue.isEmpty()) {
|
||||
const queuedRequest = this.requestQueue.dequeue();
|
||||
if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) {
|
||||
this.requestMap.delete(queuedRequest.operationId);
|
||||
this.scheduleRequest(queuedRequest);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/DateTimeFormatAndNumberFormatES2021.ts(1,29): error TS2339: Property 'formatRange' does not exist on type 'NumberFormat'.
|
||||
tests/cases/compiler/DateTimeFormatAndNumberFormatES2021.ts(4,25): error TS2339: Property 'formatRange' does not exist on type 'NumberFormat'.
|
||||
tests/cases/compiler/DateTimeFormatAndNumberFormatES2021.ts(5,25): error TS2339: Property 'formatRangeToParts' does not exist on type 'NumberFormat'.
|
||||
tests/cases/compiler/DateTimeFormatAndNumberFormatES2021.ts(5,25): error TS2551: Property 'formatRangeToParts' does not exist on type 'NumberFormat'. Did you mean 'formatToParts'?
|
||||
|
||||
|
||||
==== tests/cases/compiler/DateTimeFormatAndNumberFormatES2021.ts (3 errors) ====
|
||||
@@ -14,6 +14,7 @@ tests/cases/compiler/DateTimeFormatAndNumberFormatES2021.ts(5,25): error TS2339:
|
||||
!!! error TS2339: Property 'formatRange' does not exist on type 'NumberFormat'.
|
||||
new Intl.NumberFormat().formatRangeToParts
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'formatRangeToParts' does not exist on type 'NumberFormat'.
|
||||
!!! error TS2551: Property 'formatRangeToParts' does not exist on type 'NumberFormat'. Did you mean 'formatToParts'?
|
||||
!!! related TS2728 /.ts/lib.es2018.intl.d.ts:71:9: 'formatToParts' is declared here.
|
||||
new Intl.DateTimeFormat().formatRange
|
||||
new Intl.DateTimeFormat().formatRangeToParts
|
||||
@@ -0,0 +1,61 @@
|
||||
//// [accessorDeclarationOrder.ts]
|
||||
class C1 {
|
||||
#name: string;
|
||||
|
||||
public get name() {
|
||||
return this.#name;
|
||||
}
|
||||
|
||||
private set name(name: string) {
|
||||
this.#name = name;
|
||||
}
|
||||
}
|
||||
|
||||
class C2 {
|
||||
#name: string;
|
||||
|
||||
private set name(name: string) {
|
||||
this.#name = name;
|
||||
}
|
||||
|
||||
public get name() {
|
||||
return this.#name;
|
||||
}
|
||||
}
|
||||
|
||||
const c1 = new C1();
|
||||
const c2 = new C2();
|
||||
|
||||
|
||||
// no error
|
||||
c1.name;
|
||||
|
||||
// no error
|
||||
c2.name;
|
||||
|
||||
|
||||
//// [accessorDeclarationOrder.js]
|
||||
class C1 {
|
||||
#name;
|
||||
get name() {
|
||||
return this.#name;
|
||||
}
|
||||
set name(name) {
|
||||
this.#name = name;
|
||||
}
|
||||
}
|
||||
class C2 {
|
||||
#name;
|
||||
set name(name) {
|
||||
this.#name = name;
|
||||
}
|
||||
get name() {
|
||||
return this.#name;
|
||||
}
|
||||
}
|
||||
const c1 = new C1();
|
||||
const c2 = new C2();
|
||||
// no error
|
||||
c1.name;
|
||||
// no error
|
||||
c2.name;
|
||||
@@ -0,0 +1,72 @@
|
||||
=== tests/cases/compiler/accessorDeclarationOrder.ts ===
|
||||
class C1 {
|
||||
>C1 : Symbol(C1, Decl(accessorDeclarationOrder.ts, 0, 0))
|
||||
|
||||
#name: string;
|
||||
>#name : Symbol(C1.#name, Decl(accessorDeclarationOrder.ts, 0, 10))
|
||||
|
||||
public get name() {
|
||||
>name : Symbol(C1.name, Decl(accessorDeclarationOrder.ts, 1, 18), Decl(accessorDeclarationOrder.ts, 5, 5))
|
||||
|
||||
return this.#name;
|
||||
>this.#name : Symbol(C1.#name, Decl(accessorDeclarationOrder.ts, 0, 10))
|
||||
>this : Symbol(C1, Decl(accessorDeclarationOrder.ts, 0, 0))
|
||||
}
|
||||
|
||||
private set name(name: string) {
|
||||
>name : Symbol(C1.name, Decl(accessorDeclarationOrder.ts, 1, 18), Decl(accessorDeclarationOrder.ts, 5, 5))
|
||||
>name : Symbol(name, Decl(accessorDeclarationOrder.ts, 7, 21))
|
||||
|
||||
this.#name = name;
|
||||
>this.#name : Symbol(C1.#name, Decl(accessorDeclarationOrder.ts, 0, 10))
|
||||
>this : Symbol(C1, Decl(accessorDeclarationOrder.ts, 0, 0))
|
||||
>name : Symbol(name, Decl(accessorDeclarationOrder.ts, 7, 21))
|
||||
}
|
||||
}
|
||||
|
||||
class C2 {
|
||||
>C2 : Symbol(C2, Decl(accessorDeclarationOrder.ts, 10, 1))
|
||||
|
||||
#name: string;
|
||||
>#name : Symbol(C2.#name, Decl(accessorDeclarationOrder.ts, 12, 10))
|
||||
|
||||
private set name(name: string) {
|
||||
>name : Symbol(C2.name, Decl(accessorDeclarationOrder.ts, 13, 18), Decl(accessorDeclarationOrder.ts, 17, 5))
|
||||
>name : Symbol(name, Decl(accessorDeclarationOrder.ts, 15, 21))
|
||||
|
||||
this.#name = name;
|
||||
>this.#name : Symbol(C2.#name, Decl(accessorDeclarationOrder.ts, 12, 10))
|
||||
>this : Symbol(C2, Decl(accessorDeclarationOrder.ts, 10, 1))
|
||||
>name : Symbol(name, Decl(accessorDeclarationOrder.ts, 15, 21))
|
||||
}
|
||||
|
||||
public get name() {
|
||||
>name : Symbol(C2.name, Decl(accessorDeclarationOrder.ts, 13, 18), Decl(accessorDeclarationOrder.ts, 17, 5))
|
||||
|
||||
return this.#name;
|
||||
>this.#name : Symbol(C2.#name, Decl(accessorDeclarationOrder.ts, 12, 10))
|
||||
>this : Symbol(C2, Decl(accessorDeclarationOrder.ts, 10, 1))
|
||||
}
|
||||
}
|
||||
|
||||
const c1 = new C1();
|
||||
>c1 : Symbol(c1, Decl(accessorDeclarationOrder.ts, 24, 5))
|
||||
>C1 : Symbol(C1, Decl(accessorDeclarationOrder.ts, 0, 0))
|
||||
|
||||
const c2 = new C2();
|
||||
>c2 : Symbol(c2, Decl(accessorDeclarationOrder.ts, 25, 5))
|
||||
>C2 : Symbol(C2, Decl(accessorDeclarationOrder.ts, 10, 1))
|
||||
|
||||
|
||||
// no error
|
||||
c1.name;
|
||||
>c1.name : Symbol(C1.name, Decl(accessorDeclarationOrder.ts, 1, 18), Decl(accessorDeclarationOrder.ts, 5, 5))
|
||||
>c1 : Symbol(c1, Decl(accessorDeclarationOrder.ts, 24, 5))
|
||||
>name : Symbol(C1.name, Decl(accessorDeclarationOrder.ts, 1, 18), Decl(accessorDeclarationOrder.ts, 5, 5))
|
||||
|
||||
// no error
|
||||
c2.name;
|
||||
>c2.name : Symbol(C2.name, Decl(accessorDeclarationOrder.ts, 13, 18), Decl(accessorDeclarationOrder.ts, 17, 5))
|
||||
>c2 : Symbol(c2, Decl(accessorDeclarationOrder.ts, 25, 5))
|
||||
>name : Symbol(C2.name, Decl(accessorDeclarationOrder.ts, 13, 18), Decl(accessorDeclarationOrder.ts, 17, 5))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user