mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into assertionsInControlFlow
# Conflicts: # src/compiler/checker.ts
This commit is contained in:
commit
c3dcc37c79
215 files changed
+4009
-15586
No files matched your search
+11
-1
@@ -81,4 +81,14 @@ tests/cases/user/*/**/*.d.ts
|
||||
tests/baselines/reference/dt
|
||||
.failed-tests
|
||||
TEST-results.xml
|
||||
package-lock.json
|
||||
package-lock.json
|
||||
tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
|
||||
tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
|
||||
tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
|
||||
tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
|
||||
tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
|
||||
tests/cases/user/create-react-app/create-react-app
|
||||
tests/cases/user/webpack/webpack
|
||||
tests/cases/user/puppeteer/puppeteer
|
||||
tests/cases/user/axios-src/axios-src
|
||||
tests/cases/user/prettier/prettier
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
[submodule "tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter"]
|
||||
path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
|
||||
url = https://github.com/Microsoft/TypeScript-React-Starter
|
||||
ignore = all
|
||||
[submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"]
|
||||
path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
|
||||
url = https://github.com/Microsoft/TypeScript-Node-Starter.git
|
||||
ignore = all
|
||||
[submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"]
|
||||
path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
|
||||
url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git
|
||||
ignore = all
|
||||
[submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"]
|
||||
path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
|
||||
url = https://github.com/Microsoft/TypeScript-Vue-Starter.git
|
||||
ignore = all
|
||||
[submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"]
|
||||
path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
|
||||
url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git
|
||||
ignore = all
|
||||
[submodule "tests/cases/user/create-react-app/create-react-app"]
|
||||
path = tests/cases/user/create-react-app/create-react-app
|
||||
url = https://github.com/facebook/create-react-app.git
|
||||
ignore = all
|
||||
[submodule "tests/cases/user/webpack/webpack"]
|
||||
path = tests/cases/user/webpack/webpack
|
||||
url = https://github.com/webpack/webpack.git
|
||||
ignore = all
|
||||
[submodule "tests/cases/user/puppeteer/puppeteer"]
|
||||
path = tests/cases/user/puppeteer/puppeteer
|
||||
url = https://github.com/GoogleChrome/puppeteer.git
|
||||
ignore = all
|
||||
[submodule "tests/cases/user/axios-src/axios-src"]
|
||||
path = tests/cases/user/axios-src/axios-src
|
||||
url = https://github.com/axios/axios.git
|
||||
ignore = all
|
||||
[submodule "tests/cases/user/prettier/prettier"]
|
||||
path = tests/cases/user/prettier/prettier
|
||||
url = https://github.com/prettier/prettier.git
|
||||
ignore = all
|
||||
Vendored
+2
-3
@@ -6,8 +6,7 @@
|
||||
}
|
||||
],
|
||||
"eslint.options": {
|
||||
"rulePaths": ["../scripts/eslint/built/rules/"],
|
||||
"rulePaths": ["./scripts/eslint/built/rules/"],
|
||||
"ext": [".ts"]
|
||||
},
|
||||
"eslint.workingDirectories": ["./src", "./scripts"]
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -71,7 +71,7 @@ Design changes will not be accepted at this time. If you have a design change pr
|
||||
|
||||
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright.
|
||||
|
||||
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.pdf](https://opensource.microsoft.com/pdf/microsoft-contribution-license-agreement.pdf)), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request.
|
||||
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.pdf](https://opensource.microsoft.com/pdf/microsoft-contribution-license-agreement.pdf)), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your GitHub user name along with the agreement. Once we have received the signed CLA, we'll review the request.
|
||||
|
||||
## Housekeeping
|
||||
|
||||
@@ -148,7 +148,7 @@ You will probably only want to debug one test at a time:
|
||||
gulp runtests-browser --tests=2dArrays
|
||||
```
|
||||
|
||||
You can specify which browser to use for debugging. Currently Chrome and IE are supported:
|
||||
You can specify which browser to use for debugging. Currently, Chrome and IE are supported:
|
||||
|
||||
```Shell
|
||||
gulp runtests-browser --tests=2dArrays --browser=chrome
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
"xml2js": "^0.4.19"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "gulp build-eslint-rules",
|
||||
"pretest": "gulp tests",
|
||||
"test": "gulp runtests-parallel --light=false",
|
||||
"test:eslint-rules": "gulp run-eslint-rules-tests",
|
||||
|
||||
@@ -28,6 +28,10 @@ async function main() {
|
||||
type: "token",
|
||||
token: process.argv[2]
|
||||
});
|
||||
|
||||
// Please keep the strings "an installable tgz" and "packed" in this message, as well as the devDependencies section,
|
||||
// so that the playgrounds deployment process can find these comments.
|
||||
|
||||
await gh.issues.createComment({
|
||||
number: +process.env.SOURCE_ISSUE,
|
||||
owner: "Microsoft",
|
||||
@@ -43,6 +47,9 @@ async function main() {
|
||||
and then running \`npm install\`.
|
||||
`
|
||||
});
|
||||
|
||||
// Send a ping to https://github.com/orta/make-monaco-builds#pull-request-builds
|
||||
await gh.request("POST /repos/orta/make-monaco-builds/dispatches", { event_type: +process.env.SOURCE_ISSUE })
|
||||
}
|
||||
|
||||
main().catch(async e => {
|
||||
@@ -61,4 +68,4 @@ main().catch(async e => {
|
||||
body: `Hey @${process.env.REQUESTING_USER}, something went wrong when looking for the build artifact. ([You can check the log here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary)).`
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -2883,7 +2883,7 @@ namespace ts {
|
||||
|
||||
// If this is a property-parameter, then also declare the property symbol into the
|
||||
// containing class.
|
||||
if (isParameterPropertyDeclaration(node)) {
|
||||
if (isParameterPropertyDeclaration(node, node.parent)) {
|
||||
const classDeclaration = <ClassLikeDeclaration>node.parent.parent;
|
||||
declareSymbol(classDeclaration.symbol.members!, classDeclaration.symbol, node, SymbolFlags.Property | (node.questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
|
||||
+105
-30
@@ -60,6 +60,10 @@ namespace ts {
|
||||
* Files pending to be emitted
|
||||
*/
|
||||
affectedFilesPendingEmit?: readonly Path[] | undefined;
|
||||
/**
|
||||
* Files pending to be emitted kind.
|
||||
*/
|
||||
affectedFilesPendingEmitKind?: ReadonlyMap<BuilderFileEmit> | undefined;
|
||||
/**
|
||||
* Current index to retrieve pending affected file
|
||||
*/
|
||||
@@ -70,6 +74,11 @@ namespace ts {
|
||||
hasReusableDiagnostic?: true;
|
||||
}
|
||||
|
||||
export const enum BuilderFileEmit {
|
||||
DtsOnly,
|
||||
Full
|
||||
}
|
||||
|
||||
/**
|
||||
* State to store the changed files, affected files and cache semantic diagnostics
|
||||
*/
|
||||
@@ -127,7 +136,11 @@ namespace ts {
|
||||
/**
|
||||
* Files pending to be emitted
|
||||
*/
|
||||
affectedFilesPendingEmit: readonly Path[] | undefined;
|
||||
affectedFilesPendingEmit: Path[] | undefined;
|
||||
/**
|
||||
* Files pending to be emitted kind.
|
||||
*/
|
||||
affectedFilesPendingEmitKind: Map<BuilderFileEmit> | undefined;
|
||||
/**
|
||||
* Current index to retrieve pending affected file
|
||||
*/
|
||||
@@ -139,7 +152,7 @@ namespace ts {
|
||||
/**
|
||||
* Already seen emitted files
|
||||
*/
|
||||
seenEmittedFiles: Map<true> | undefined;
|
||||
seenEmittedFiles: Map<BuilderFileEmit> | undefined;
|
||||
/**
|
||||
* true if program has been emitted
|
||||
*/
|
||||
@@ -160,8 +173,7 @@ namespace ts {
|
||||
const compilerOptions = newProgram.getCompilerOptions();
|
||||
state.compilerOptions = compilerOptions;
|
||||
// With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
|
||||
// With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors
|
||||
if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) {
|
||||
if (!compilerOptions.outFile && !compilerOptions.out) {
|
||||
state.semanticDiagnosticsPerFile = createMap<readonly Diagnostic[]>();
|
||||
}
|
||||
state.changedFilesSet = createMap<true>();
|
||||
@@ -186,7 +198,8 @@ namespace ts {
|
||||
copyEntries(changedFilesSet, state.changedFilesSet);
|
||||
}
|
||||
if (!compilerOptions.outFile && !compilerOptions.out && oldState!.affectedFilesPendingEmit) {
|
||||
state.affectedFilesPendingEmit = oldState!.affectedFilesPendingEmit;
|
||||
state.affectedFilesPendingEmit = oldState!.affectedFilesPendingEmit.slice();
|
||||
state.affectedFilesPendingEmitKind = cloneMapOrUndefined(oldState!.affectedFilesPendingEmitKind);
|
||||
state.affectedFilesPendingEmitIndex = oldState!.affectedFilesPendingEmitIndex;
|
||||
}
|
||||
}
|
||||
@@ -233,7 +246,7 @@ namespace ts {
|
||||
|
||||
if (oldCompilerOptions && compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
|
||||
// Add all files to affectedFilesPendingEmit since emit changed
|
||||
addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(f => f.path));
|
||||
newProgram.getSourceFiles().forEach(f => addToAffectedFilesPendingEmit(state, f.path, BuilderFileEmit.Full));
|
||||
Debug.assert(state.seenAffectedFiles === undefined);
|
||||
state.seenAffectedFiles = createMap<true>();
|
||||
}
|
||||
@@ -243,7 +256,7 @@ namespace ts {
|
||||
|
||||
function convertToDiagnostics(diagnostics: readonly ReusableDiagnostic[], newProgram: Program, getCanonicalFileName: GetCanonicalFileName): readonly Diagnostic[] {
|
||||
if (!diagnostics.length) return emptyArray;
|
||||
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getOutputPathForBuildInfo(newProgram.getCompilerOptions())!, newProgram.getCurrentDirectory()));
|
||||
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions())!, newProgram.getCurrentDirectory()));
|
||||
return diagnostics.map(diagnostic => {
|
||||
const result: Diagnostic = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
|
||||
result.reportsUnnecessary = diagnostic.reportsUnnecessary;
|
||||
@@ -295,7 +308,8 @@ namespace ts {
|
||||
newState.semanticDiagnosticsFromOldState = cloneMapOrUndefined(state.semanticDiagnosticsFromOldState);
|
||||
newState.program = state.program;
|
||||
newState.compilerOptions = state.compilerOptions;
|
||||
newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit;
|
||||
newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
|
||||
newState.affectedFilesPendingEmitKind = cloneMapOrUndefined(state.affectedFilesPendingEmitKind);
|
||||
newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
|
||||
newState.seenEmittedFiles = cloneMapOrUndefined(state.seenEmittedFiles);
|
||||
newState.programEmitComplete = state.programEmitComplete;
|
||||
@@ -373,19 +387,24 @@ namespace ts {
|
||||
/**
|
||||
* Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
|
||||
*/
|
||||
function getNextAffectedFilePendingEmit(state: BuilderProgramState): SourceFile | undefined {
|
||||
function getNextAffectedFilePendingEmit(state: BuilderProgramState) {
|
||||
const { affectedFilesPendingEmit } = state;
|
||||
if (affectedFilesPendingEmit) {
|
||||
const seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = createMap());
|
||||
for (let i = state.affectedFilesPendingEmitIndex!; i < affectedFilesPendingEmit.length; i++) {
|
||||
const affectedFile = Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
|
||||
if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) {
|
||||
// emit this file
|
||||
state.affectedFilesPendingEmitIndex = i;
|
||||
return affectedFile;
|
||||
if (affectedFile) {
|
||||
const seenKind = seenEmittedFiles.get(affectedFile.path);
|
||||
const emitKind = Debug.assertDefined(Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path));
|
||||
if (seenKind === undefined || seenKind < emitKind) {
|
||||
// emit this file
|
||||
state.affectedFilesPendingEmitIndex = i;
|
||||
return { affectedFile, emitKind };
|
||||
}
|
||||
}
|
||||
}
|
||||
state.affectedFilesPendingEmit = undefined;
|
||||
state.affectedFilesPendingEmitKind = undefined;
|
||||
state.affectedFilesPendingEmitIndex = undefined;
|
||||
}
|
||||
return undefined;
|
||||
@@ -442,7 +461,7 @@ namespace ts {
|
||||
);
|
||||
// If not dts emit, nothing more to do
|
||||
if (getEmitDeclarations(state.compilerOptions)) {
|
||||
addToAffectedFilesPendingEmit(state, [path]);
|
||||
addToAffectedFilesPendingEmit(state, path, BuilderFileEmit.DtsOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -463,16 +482,43 @@ namespace ts {
|
||||
return !state.semanticDiagnosticsFromOldState.size;
|
||||
}
|
||||
|
||||
function isChangedSignagure(state: BuilderProgramState, path: Path) {
|
||||
const newSignature = Debug.assertDefined(state.currentAffectedFilesSignatures).get(path);
|
||||
const oldSignagure = Debug.assertDefined(state.fileInfos.get(path)).signature;
|
||||
return newSignature !== oldSignagure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate on referencing modules that export entities from affected file
|
||||
*/
|
||||
function forEachReferencingModulesOfExportOfAffectedFile(state: BuilderProgramState, affectedFile: SourceFile, fn: (state: BuilderProgramState, filePath: Path) => boolean) {
|
||||
// If there was change in signature (dts output) for the changed file,
|
||||
// then only we need to handle pending file emit
|
||||
if (!state.exportedModulesMap || state.affectedFiles!.length === 1 || !state.changedFilesSet.has(affectedFile.path)) {
|
||||
if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isChangedSignagure(state, affectedFile.path)) return;
|
||||
|
||||
// Since isolated modules dont change js files, files affected by change in signature is itself
|
||||
// But we need to cleanup semantic diagnostics and queue dts emit for affected files
|
||||
if (state.compilerOptions.isolatedModules) {
|
||||
const seenFileNamesMap = createMap<true>();
|
||||
seenFileNamesMap.set(affectedFile.path, true);
|
||||
const queue = BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);
|
||||
while (queue.length > 0) {
|
||||
const currentPath = queue.pop()!;
|
||||
if (!seenFileNamesMap.has(currentPath)) {
|
||||
seenFileNamesMap.set(currentPath, true);
|
||||
const result = fn(state, currentPath);
|
||||
if (result && isChangedSignagure(state, currentPath)) {
|
||||
const currentSourceFile = Debug.assertDefined(state.program).getSourceFileByPath(currentPath)!;
|
||||
queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
|
||||
const seenFileAndExportsOfFile = createMap<true>();
|
||||
// Go through exported modules from cache first
|
||||
@@ -548,7 +594,13 @@ namespace ts {
|
||||
* This is called after completing operation on the next affected file.
|
||||
* The operations here are postponed to ensure that cancellation during the iteration is handled correctly
|
||||
*/
|
||||
function doneWithAffectedFile(state: BuilderProgramState, affected: SourceFile | Program, isPendingEmit?: boolean, isBuildInfoEmit?: boolean, isEmitResult?: boolean) {
|
||||
function doneWithAffectedFile(
|
||||
state: BuilderProgramState,
|
||||
affected: SourceFile | Program,
|
||||
emitKind?: BuilderFileEmit,
|
||||
isPendingEmit?: boolean,
|
||||
isBuildInfoEmit?: boolean
|
||||
) {
|
||||
if (isBuildInfoEmit) {
|
||||
state.emittedBuildInfo = true;
|
||||
}
|
||||
@@ -558,8 +610,8 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
state.seenAffectedFiles!.set((affected as SourceFile).path, true);
|
||||
if (isEmitResult) {
|
||||
(state.seenEmittedFiles || (state.seenEmittedFiles = createMap())).set((affected as SourceFile).path, true);
|
||||
if (emitKind !== undefined) {
|
||||
(state.seenEmittedFiles || (state.seenEmittedFiles = createMap())).set((affected as SourceFile).path, emitKind);
|
||||
}
|
||||
if (isPendingEmit) {
|
||||
state.affectedFilesPendingEmitIndex!++;
|
||||
@@ -573,16 +625,23 @@ namespace ts {
|
||||
/**
|
||||
* Returns the result with affected file
|
||||
*/
|
||||
function toAffectedFileResult<T>(state: BuilderProgramState, result: T, affected: SourceFile | Program, isPendingEmit?: boolean, isBuildInfoEmit?: boolean): AffectedFileResult<T> {
|
||||
doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit);
|
||||
function toAffectedFileResult<T>(state: BuilderProgramState, result: T, affected: SourceFile | Program): AffectedFileResult<T> {
|
||||
doneWithAffectedFile(state, affected);
|
||||
return { result, affected };
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the result with affected file
|
||||
*/
|
||||
function toAffectedFileEmitResult(state: BuilderProgramState, result: EmitResult, affected: SourceFile | Program, isPendingEmit?: boolean, isBuildInfoEmit?: boolean): AffectedFileResult<EmitResult> {
|
||||
doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, /*isEmitResult*/ true);
|
||||
function toAffectedFileEmitResult(
|
||||
state: BuilderProgramState,
|
||||
result: EmitResult,
|
||||
affected: SourceFile | Program,
|
||||
emitKind: BuilderFileEmit,
|
||||
isPendingEmit?: boolean,
|
||||
isBuildInfoEmit?: boolean
|
||||
): AffectedFileResult<EmitResult> {
|
||||
doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit);
|
||||
return { result, affected };
|
||||
}
|
||||
|
||||
@@ -623,7 +682,7 @@ namespace ts {
|
||||
function getProgramBuildInfo(state: Readonly<ReusableBuilderProgramState>, getCanonicalFileName: GetCanonicalFileName): ProgramBuildInfo | undefined {
|
||||
if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined;
|
||||
const currentDirectory = Debug.assertDefined(state.program).getCurrentDirectory();
|
||||
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getOutputPathForBuildInfo(state.compilerOptions)!, currentDirectory));
|
||||
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions)!, currentDirectory));
|
||||
const fileInfos: MapLike<BuilderState.FileInfo> = {};
|
||||
state.fileInfos.forEach((value, key) => {
|
||||
const signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
|
||||
@@ -849,11 +908,12 @@ namespace ts {
|
||||
*/
|
||||
function emitNextAffectedFile(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): AffectedFileResult<EmitResult> {
|
||||
let affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
||||
let emitKind = BuilderFileEmit.Full;
|
||||
let isPendingEmitFile = false;
|
||||
if (!affected) {
|
||||
if (!state.compilerOptions.out && !state.compilerOptions.outFile) {
|
||||
affected = getNextAffectedFilePendingEmit(state);
|
||||
if (!affected) {
|
||||
const pendingAffectedFile = getNextAffectedFilePendingEmit(state);
|
||||
if (!pendingAffectedFile) {
|
||||
if (state.emittedBuildInfo) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -865,10 +925,12 @@ namespace ts {
|
||||
// Otherwise just affected file
|
||||
affected.emitBuildInfo(writeFile || maybeBind(host, host.writeFile), cancellationToken),
|
||||
affected,
|
||||
/*emitKind*/ BuilderFileEmit.Full,
|
||||
/*isPendingEmitFile*/ false,
|
||||
/*isBuildInfoEmit*/ true
|
||||
);
|
||||
}
|
||||
({ affectedFile: affected, emitKind } = pendingAffectedFile);
|
||||
isPendingEmitFile = true;
|
||||
}
|
||||
else {
|
||||
@@ -886,10 +948,17 @@ namespace ts {
|
||||
state,
|
||||
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
|
||||
// Otherwise just affected file
|
||||
Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected as SourceFile, writeFile || maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers),
|
||||
Debug.assertDefined(state.program).emit(
|
||||
affected === state.program ? undefined : affected as SourceFile,
|
||||
writeFile || maybeBind(host, host.writeFile),
|
||||
cancellationToken,
|
||||
emitOnlyDtsFiles || emitKind === BuilderFileEmit.DtsOnly,
|
||||
customTransformers
|
||||
),
|
||||
affected,
|
||||
emitKind,
|
||||
isPendingEmitFile,
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -953,7 +1022,7 @@ namespace ts {
|
||||
|
||||
// Add file to affected file pending emit to handle for later emit time
|
||||
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
||||
addToAffectedFilesPendingEmit(state, [(affected as SourceFile).path]);
|
||||
addToAffectedFilesPendingEmit(state, (affected as SourceFile).path, BuilderFileEmit.Full);
|
||||
}
|
||||
|
||||
// Get diagnostics for the affected file if its not ignored
|
||||
@@ -1006,8 +1075,14 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFilesPendingEmit: readonly Path[]) {
|
||||
state.affectedFilesPendingEmit = concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit);
|
||||
function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFilePendingEmit: Path, kind: BuilderFileEmit) {
|
||||
if (!state.affectedFilesPendingEmit) state.affectedFilesPendingEmit = [];
|
||||
if (!state.affectedFilesPendingEmitKind) state.affectedFilesPendingEmitKind = createMap();
|
||||
|
||||
const existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit);
|
||||
state.affectedFilesPendingEmit.push(affectedFilePendingEmit);
|
||||
state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind);
|
||||
|
||||
// affectedFilesPendingEmitIndex === undefined
|
||||
// - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files
|
||||
// so start from 0 as array would be affectedFilesPendingEmit
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace ts {
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function getFileEmitOutput(program: Program, sourceFile: SourceFile, emitOnlyDtsFiles: boolean,
|
||||
cancellationToken?: CancellationToken, customTransformers?: CustomTransformers): EmitOutput {
|
||||
cancellationToken?: CancellationToken, customTransformers?: CustomTransformers, forceDtsEmit?: boolean): EmitOutput {
|
||||
const outputFiles: OutputFile[] = [];
|
||||
const emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
|
||||
const emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit);
|
||||
return { outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit };
|
||||
|
||||
function writeFile(fileName: string, text: string, writeByteOrderMark: boolean) {
|
||||
@@ -344,7 +344,14 @@ namespace ts.BuilderState {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const emitOutput = getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken);
|
||||
const emitOutput = getFileEmitOutput(
|
||||
programOfThisState,
|
||||
sourceFile,
|
||||
/*emitOnlyDtsFiles*/ true,
|
||||
cancellationToken,
|
||||
/*customTransformers*/ undefined,
|
||||
/*forceDtsEmit*/ true
|
||||
);
|
||||
const firstDts = emitOutput.outputFiles &&
|
||||
programOfThisState.getCompilerOptions().declarationMap ?
|
||||
emitOutput.outputFiles.length > 1 ? emitOutput.outputFiles[1] : undefined :
|
||||
@@ -459,7 +466,7 @@ namespace ts.BuilderState {
|
||||
/**
|
||||
* Gets the files referenced by the the file path
|
||||
*/
|
||||
function getReferencedByPaths(state: Readonly<BuilderState>, referencedFilePath: Path) {
|
||||
export function getReferencedByPaths(state: Readonly<BuilderState>, referencedFilePath: Path) {
|
||||
return arrayFrom(mapDefinedIterator(state.referencedMap!.entries(), ([filePath, referencesInFile]) =>
|
||||
referencesInFile.has(referencedFilePath) ? filePath as Path : undefined
|
||||
));
|
||||
|
||||
+96
-61
@@ -820,6 +820,7 @@ namespace ts {
|
||||
let flowLoopCount = 0;
|
||||
let sharedFlowCount = 0;
|
||||
let flowAnalysisDisabled = false;
|
||||
let flowInvocationCount = 0;
|
||||
let lastFlowNode: FlowNode | undefined;
|
||||
let lastFlowNodeReachable: boolean;
|
||||
|
||||
@@ -837,8 +838,7 @@ namespace ts {
|
||||
const symbolLinks: SymbolLinks[] = [];
|
||||
const nodeLinks: NodeLinks[] = [];
|
||||
const flowLoopCaches: Map<Type>[] = [];
|
||||
const flowAssignmentKeys: string[] = [];
|
||||
const flowAssignmentTypes: FlowType[] = [];
|
||||
const flowAssignmentTypes: Type[] = [];
|
||||
const flowLoopNodes: FlowNode[] = [];
|
||||
const flowLoopKeys: string[] = [];
|
||||
const flowLoopTypes: Type[][] = [];
|
||||
@@ -8966,9 +8966,8 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getConstraintDeclaration(type: TypeParameter) {
|
||||
const decl = type.symbol && getDeclarationOfKind<TypeParameterDeclaration>(type.symbol, SyntaxKind.TypeParameter);
|
||||
return decl && getEffectiveConstraintOfTypeParameter(decl);
|
||||
function getConstraintDeclaration(type: TypeParameter): TypeNode | undefined {
|
||||
return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
|
||||
}
|
||||
|
||||
function getInferredTypeParameterConstraint(typeParameter: TypeParameter) {
|
||||
@@ -14986,9 +14985,9 @@ namespace ts {
|
||||
* Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module
|
||||
* with no call or construct signatures.
|
||||
*/
|
||||
function isObjectTypeWithInferableIndex(type: Type) {
|
||||
return type.symbol && (type.symbol.flags & (SymbolFlags.ObjectLiteral | SymbolFlags.TypeLiteral | SymbolFlags.Enum | SymbolFlags.ValueModule)) !== 0 &&
|
||||
!typeHasCallOrConstructSignatures(type);
|
||||
function isObjectTypeWithInferableIndex(type: Type): boolean {
|
||||
return !!(type.symbol && (type.symbol.flags & (SymbolFlags.ObjectLiteral | SymbolFlags.TypeLiteral | SymbolFlags.Enum | SymbolFlags.ValueModule)) !== 0 &&
|
||||
!typeHasCallOrConstructSignatures(type)) || !!(getObjectFlags(type) & ObjectFlags.ReverseMapped && isObjectTypeWithInferableIndex((type as ReverseMappedType).source));
|
||||
}
|
||||
|
||||
function createSymbolWithType(source: Symbol, type: Type | undefined) {
|
||||
@@ -15389,6 +15388,13 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function cloneInferredPartOfContext(context: InferenceContext): InferenceContext | undefined {
|
||||
const inferences = filter(context.inferences, hasInferenceCandidates);
|
||||
return inferences.length ?
|
||||
createInferenceContextWorker(map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) :
|
||||
undefined;
|
||||
}
|
||||
|
||||
function getMapperFromContext<T extends InferenceContext | undefined>(context: T): TypeMapper | T & undefined {
|
||||
return context && context.mapper;
|
||||
}
|
||||
@@ -16673,12 +16679,6 @@ namespace ts {
|
||||
getInitialTypeOfBindingElement(node);
|
||||
}
|
||||
|
||||
function getInitialOrAssignedType(node: VariableDeclaration | BindingElement | Expression, reference: Node) {
|
||||
return getConstraintForLocation(node.kind === SyntaxKind.VariableDeclaration || node.kind === SyntaxKind.BindingElement ?
|
||||
getInitialType(<VariableDeclaration | BindingElement>node) :
|
||||
getAssignedType(node), reference);
|
||||
}
|
||||
|
||||
function isEmptyArrayAssignment(node: VariableDeclaration | BindingElement | Expression) {
|
||||
return node.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>node).initializer &&
|
||||
isEmptyArrayLiteral((<VariableDeclaration>node).initializer!) ||
|
||||
@@ -17071,6 +17071,7 @@ namespace ts {
|
||||
if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) {
|
||||
return declaredType;
|
||||
}
|
||||
flowInvocationCount++;
|
||||
const sharedFlowStart = sharedFlowCount;
|
||||
const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
|
||||
sharedFlowCount = sharedFlowStart;
|
||||
@@ -17103,16 +17104,6 @@ namespace ts {
|
||||
flowDepth++;
|
||||
while (true) {
|
||||
const flags = flow.flags;
|
||||
if (flags & FlowFlags.Cached) {
|
||||
const key = getOrSetCacheKey();
|
||||
if (key) {
|
||||
const id = getFlowNodeId(flow);
|
||||
if (flowAssignmentKeys[id] === key) {
|
||||
flowDepth--;
|
||||
return flowAssignmentTypes[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flags & FlowFlags.Shared) {
|
||||
// We cache results of flow type resolution for shared nodes that were previously visited in
|
||||
// the same getFlowTypeOfReference invocation. A node is considered shared when it is the
|
||||
@@ -17143,15 +17134,6 @@ namespace ts {
|
||||
flow = (<FlowAssignment>flow).antecedent;
|
||||
continue;
|
||||
}
|
||||
else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis
|
||||
const key = getOrSetCacheKey();
|
||||
if (key && !isIncomplete(type)) {
|
||||
flow.flags |= FlowFlags.Cached;
|
||||
const id = getFlowNodeId(flow);
|
||||
flowAssignmentKeys[id] = key;
|
||||
flowAssignmentTypes[id] = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flags & FlowFlags.Call) {
|
||||
type = getTypeAtFlowCall(<FlowCall>flow);
|
||||
@@ -17211,6 +17193,27 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getInitialOrAssignedType(flow: FlowAssignment) {
|
||||
const node = flow.node;
|
||||
if (flow.flags & FlowFlags.Cached) {
|
||||
const cached = flowAssignmentTypes[getNodeId(node)];
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
const startInvocationCount = flowInvocationCount;
|
||||
const type = getConstraintForLocation(node.kind === SyntaxKind.VariableDeclaration || node.kind === SyntaxKind.BindingElement ?
|
||||
getInitialType(<VariableDeclaration | BindingElement>node) :
|
||||
getAssignedType(node), reference);
|
||||
// We cache the assigned type when getFlowTypeOfReference was recursively invoked in the
|
||||
// resolution of the assigned type and we're not within loop analysis.
|
||||
if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) {
|
||||
flow.flags |= FlowFlags.Cached;
|
||||
flowAssignmentTypes[getNodeId(node)] = type;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function getTypeAtFlowAssignment(flow: FlowAssignment) {
|
||||
const node = flow.node;
|
||||
// Assignments only narrow the computed type if the declared type is a union type. Thus, we
|
||||
@@ -17227,11 +17230,11 @@ namespace ts {
|
||||
if (isEmptyArrayAssignment(node)) {
|
||||
return getEvolvingArrayType(neverType);
|
||||
}
|
||||
const assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference));
|
||||
const assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow));
|
||||
return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
|
||||
}
|
||||
if (declaredType.flags & TypeFlags.Union) {
|
||||
return getAssignmentReducedType(<UnionType>declaredType, getInitialOrAssignedType(node, reference));
|
||||
return getAssignmentReducedType(<UnionType>declaredType, getInitialOrAssignedType(flow));
|
||||
}
|
||||
return declaredType;
|
||||
}
|
||||
@@ -17439,24 +17442,31 @@ namespace ts {
|
||||
const antecedentTypes: Type[] = [];
|
||||
let subtypeReduction = false;
|
||||
let firstAntecedentType: FlowType | undefined;
|
||||
flowLoopNodes[flowLoopCount] = flow;
|
||||
flowLoopKeys[flowLoopCount] = key;
|
||||
flowLoopTypes[flowLoopCount] = antecedentTypes;
|
||||
for (const antecedent of flow.antecedents!) {
|
||||
flowLoopCount++;
|
||||
const flowType = getTypeAtFlowNode(antecedent);
|
||||
flowLoopCount--;
|
||||
let flowType;
|
||||
if (!firstAntecedentType) {
|
||||
firstAntecedentType = flowType;
|
||||
// The first antecedent of a loop junction is always the non-looping control
|
||||
// flow path that leads to the top.
|
||||
flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
|
||||
}
|
||||
else {
|
||||
// All but the first antecedent are the looping control flow paths that lead
|
||||
// back to the loop junction. We track these on the flow loop stack.
|
||||
flowLoopNodes[flowLoopCount] = flow;
|
||||
flowLoopKeys[flowLoopCount] = key;
|
||||
flowLoopTypes[flowLoopCount] = antecedentTypes;
|
||||
flowLoopCount++;
|
||||
flowType = getTypeAtFlowNode(antecedent);
|
||||
flowLoopCount--;
|
||||
// If we see a value appear in the cache it is a sign that control flow analysis
|
||||
// was restarted and completed by checkExpressionCached. We can simply pick up
|
||||
// the resulting type and bail out.
|
||||
const cached = cache.get(key);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
const type = getTypeFromFlowType(flowType);
|
||||
// If we see a value appear in the cache it is a sign that control flow analysis
|
||||
// was restarted and completed by checkExpressionCached. We can simply pick up
|
||||
// the resulting type and bail out.
|
||||
const cached = cache.get(key);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
pushIfUnique(antecedentTypes, type);
|
||||
// If an antecedent type is not a subset of the declared type, we need to perform
|
||||
// subtype reduction. This happens when a "foreign" type is injected into the control
|
||||
@@ -17589,7 +17599,7 @@ namespace ts {
|
||||
assumeTrue = !assumeTrue;
|
||||
}
|
||||
const valueType = getTypeOfExpression(value);
|
||||
if ((type.flags & TypeFlags.Unknown) && (operator === SyntaxKind.EqualsEqualsEqualsToken) && assumeTrue) {
|
||||
if ((type.flags & TypeFlags.Unknown) && assumeTrue && (operator === SyntaxKind.EqualsEqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken)) {
|
||||
if (valueType.flags & (TypeFlags.Primitive | TypeFlags.NonPrimitive)) {
|
||||
return valueType;
|
||||
}
|
||||
@@ -18196,7 +18206,7 @@ namespace ts {
|
||||
// the entire control flow graph from the variable's declaration (i.e. when the flow container and
|
||||
// declaration container are the same).
|
||||
const assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isBindingElement(declaration) ||
|
||||
type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & TypeFlags.AnyOrUnknown) !== 0 ||
|
||||
type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (TypeFlags.AnyOrUnknown | TypeFlags.Void)) !== 0 ||
|
||||
isInTypeQuery(node) || node.parent.kind === SyntaxKind.ExportSpecifier) ||
|
||||
node.parent.kind === SyntaxKind.NonNullExpression ||
|
||||
declaration.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>declaration).exclamationToken ||
|
||||
@@ -21602,7 +21612,7 @@ namespace ts {
|
||||
const returnContext = createInferenceContext(signature.typeParameters!, signature, context.flags);
|
||||
const returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
|
||||
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
|
||||
context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined;
|
||||
context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25839,7 +25849,7 @@ namespace ts {
|
||||
for (const member of node.members) {
|
||||
if (member.kind === SyntaxKind.Constructor) {
|
||||
for (const param of (member as ConstructorDeclaration).parameters) {
|
||||
if (isParameterPropertyDeclaration(param) && !isBindingPattern(param.name)) {
|
||||
if (isParameterPropertyDeclaration(param, member) && !isBindingPattern(param.name)) {
|
||||
addName(instanceNames, param.name, param.name.escapedText, DeclarationMeaning.GetOrSetAccessor);
|
||||
}
|
||||
}
|
||||
@@ -27603,7 +27613,7 @@ namespace ts {
|
||||
const parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);
|
||||
const name = local.valueDeclaration && getNameOfDeclaration(local.valueDeclaration);
|
||||
if (parameter && name) {
|
||||
if (!isParameterPropertyDeclaration(parameter) && !parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
|
||||
if (!isParameterPropertyDeclaration(parameter, parameter.parent) && !parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
|
||||
addDiagnostic(parameter, UnusedKind.Parameter, createDiagnosticForNode(name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolName(local)));
|
||||
}
|
||||
}
|
||||
@@ -28874,11 +28884,13 @@ namespace ts {
|
||||
let nextType: Type | undefined;
|
||||
if (methodName !== "throw") {
|
||||
const methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
|
||||
const resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
|
||||
if (methodName === "next") {
|
||||
nextType = resolvedMethodParameterType;
|
||||
// The value of `next(value)` is *not* awaited by async generators
|
||||
nextType = methodParameterType;
|
||||
}
|
||||
else if (methodName === "return") {
|
||||
// The value of `return(value)` *is* awaited by async generators
|
||||
const resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
|
||||
returnTypes = append(returnTypes, resolvedMethodParameterType);
|
||||
}
|
||||
}
|
||||
@@ -29367,11 +29379,10 @@ namespace ts {
|
||||
const constraint = getEffectiveConstraintOfTypeParameter(source);
|
||||
const sourceConstraint = constraint && getTypeFromTypeNode(constraint);
|
||||
const targetConstraint = getConstraintOfTypeParameter(target);
|
||||
if (sourceConstraint) {
|
||||
// relax check if later interface augmentation has no constraint
|
||||
if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
|
||||
return false;
|
||||
}
|
||||
// relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with
|
||||
// a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill)
|
||||
if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the type parameter node has a default and it is not identical to the default
|
||||
@@ -33852,9 +33863,33 @@ namespace ts {
|
||||
return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
|
||||
}
|
||||
}
|
||||
|
||||
// Realism (size) checking
|
||||
checkNumericLiteralValueSize(node);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkNumericLiteralValueSize(node: NumericLiteral) {
|
||||
// Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint
|
||||
// Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1
|
||||
// Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway
|
||||
if (node.numericLiteralFlags & TokenFlags.Scientific || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can't rely on the runtime to accurately store and compare extremely large numeric values
|
||||
// Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298
|
||||
// Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER,
|
||||
// it's likely addition operations on it will fail too
|
||||
const apparentValue = +getTextOfNode(node);
|
||||
if (apparentValue <= 2 ** 53 - 1 && apparentValue + 1 > apparentValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
addErrorOrSuggestion(/*isError*/ false, createDiagnosticForNode(node, Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers));
|
||||
}
|
||||
|
||||
function checkGrammarBigIntLiteral(node: BigIntLiteral): boolean {
|
||||
const literalType = isLiteralTypeNode(node.parent) ||
|
||||
isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent);
|
||||
|
||||
@@ -1035,6 +1035,10 @@
|
||||
"category": "Error",
|
||||
"code": 1356
|
||||
},
|
||||
"An enum member name must be followed by a ',', '=', or '}'.": {
|
||||
"category": "Error",
|
||||
"code": 1357
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
@@ -4643,6 +4647,10 @@
|
||||
"category": "Suggestion",
|
||||
"code": 80007
|
||||
},
|
||||
"Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers.": {
|
||||
"category": "Suggestion",
|
||||
"code": 80008
|
||||
},
|
||||
|
||||
"Add missing 'super()' call": {
|
||||
"category": "Message",
|
||||
@@ -5124,6 +5132,18 @@
|
||||
"category": "Message",
|
||||
"code": 95090
|
||||
},
|
||||
"Convert to a bigint numeric literal": {
|
||||
"category": "Message",
|
||||
"code": 95091
|
||||
},
|
||||
"Convert all to bigint numeric literals": {
|
||||
"category": "Message",
|
||||
"code": 95092
|
||||
},
|
||||
"Convert 'const' to 'let'": {
|
||||
"category": "Message",
|
||||
"code": 95093
|
||||
},
|
||||
|
||||
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
|
||||
"category": "Error",
|
||||
|
||||
+75
-36
@@ -20,7 +20,7 @@ namespace ts {
|
||||
export function forEachEmittedFile<T>(
|
||||
host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle | undefined) => T,
|
||||
sourceFilesOrTargetSourceFile?: readonly SourceFile[] | SourceFile,
|
||||
emitOnlyDtsFiles = false,
|
||||
forceDtsEmit = false,
|
||||
onlyBuildInfo?: boolean,
|
||||
includeBuildInfo?: boolean) {
|
||||
const sourceFiles = isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile);
|
||||
@@ -29,7 +29,7 @@ namespace ts {
|
||||
const prepends = host.getPrependNodes();
|
||||
if (sourceFiles.length || prepends.length) {
|
||||
const bundle = createBundle(sourceFiles, prepends);
|
||||
const result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle);
|
||||
const result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -38,21 +38,20 @@ namespace ts {
|
||||
else {
|
||||
if (!onlyBuildInfo) {
|
||||
for (const sourceFile of sourceFiles) {
|
||||
const result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile);
|
||||
const result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (includeBuildInfo) {
|
||||
const buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions());
|
||||
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions());
|
||||
if (buildInfoPath) return action({ buildInfoPath }, /*sourceFileOrBundle*/ undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getOutputPathForBuildInfo(options: CompilerOptions) {
|
||||
export function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions) {
|
||||
const configFile = options.configFilePath;
|
||||
if (!isIncrementalCompilation(options)) return undefined;
|
||||
if (options.tsBuildInfoFile) return options.tsBuildInfoFile;
|
||||
@@ -80,7 +79,7 @@ namespace ts {
|
||||
const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
|
||||
const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? removeFileExtension(outPath) + Extension.Dts : undefined;
|
||||
const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
|
||||
const buildInfoPath = getOutputPathForBuildInfo(options);
|
||||
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
|
||||
return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath };
|
||||
}
|
||||
|
||||
@@ -170,38 +169,71 @@ namespace ts {
|
||||
undefined;
|
||||
}
|
||||
|
||||
function createAddOutput() {
|
||||
let outputs: string[] | undefined;
|
||||
return { addOutput, getOutputs };
|
||||
function addOutput(path: string | undefined) {
|
||||
if (path) {
|
||||
(outputs || (outputs = [])).push(path);
|
||||
}
|
||||
}
|
||||
function getOutputs(): readonly string[] {
|
||||
return outputs || emptyArray;
|
||||
}
|
||||
}
|
||||
|
||||
function getSingleOutputFileNames(configFile: ParsedCommandLine, addOutput: ReturnType<typeof createAddOutput>["addOutput"]) {
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath } = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false);
|
||||
addOutput(jsFilePath);
|
||||
addOutput(sourceMapFilePath);
|
||||
addOutput(declarationFilePath);
|
||||
addOutput(declarationMapPath);
|
||||
addOutput(buildInfoPath);
|
||||
}
|
||||
|
||||
function getOwnOutputFileNames(configFile: ParsedCommandLine, inputFileName: string, ignoreCase: boolean, addOutput: ReturnType<typeof createAddOutput>["addOutput"]) {
|
||||
if (fileExtensionIs(inputFileName, Extension.Dts)) return;
|
||||
const js = getOutputJSFileName(inputFileName, configFile, ignoreCase);
|
||||
addOutput(js);
|
||||
if (fileExtensionIs(inputFileName, Extension.Json)) return;
|
||||
if (js && configFile.options.sourceMap) {
|
||||
addOutput(`${js}.map`);
|
||||
}
|
||||
if (getEmitDeclarations(configFile.options) && hasTSFileExtension(inputFileName)) {
|
||||
const dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
|
||||
addOutput(dts);
|
||||
if (configFile.options.declarationMap) {
|
||||
addOutput(`${dts}.map`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getAllProjectOutputs(configFile: ParsedCommandLine, ignoreCase: boolean): readonly string[] {
|
||||
let outputs: string[] | undefined;
|
||||
const addOutput = (path: string | undefined) => path && (outputs || (outputs = [])).push(path);
|
||||
const { addOutput, getOutputs } = createAddOutput();
|
||||
if (configFile.options.outFile || configFile.options.out) {
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath } = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false);
|
||||
addOutput(jsFilePath);
|
||||
addOutput(sourceMapFilePath);
|
||||
addOutput(declarationFilePath);
|
||||
addOutput(declarationMapPath);
|
||||
addOutput(buildInfoPath);
|
||||
getSingleOutputFileNames(configFile, addOutput);
|
||||
}
|
||||
else {
|
||||
for (const inputFileName of configFile.fileNames) {
|
||||
if (fileExtensionIs(inputFileName, Extension.Dts)) continue;
|
||||
const js = getOutputJSFileName(inputFileName, configFile, ignoreCase);
|
||||
addOutput(js);
|
||||
if (fileExtensionIs(inputFileName, Extension.Json)) continue;
|
||||
if (js && configFile.options.sourceMap) {
|
||||
addOutput(`${js}.map`);
|
||||
}
|
||||
if (getEmitDeclarations(configFile.options) && hasTSFileExtension(inputFileName)) {
|
||||
const dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
|
||||
addOutput(dts);
|
||||
if (configFile.options.declarationMap) {
|
||||
addOutput(`${dts}.map`);
|
||||
}
|
||||
}
|
||||
getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput);
|
||||
}
|
||||
addOutput(getOutputPathForBuildInfo(configFile.options));
|
||||
addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
|
||||
}
|
||||
return outputs || emptyArray;
|
||||
return getOutputs();
|
||||
}
|
||||
|
||||
export function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[] {
|
||||
inputFileName = normalizePath(inputFileName);
|
||||
Debug.assert(contains(commandLine.fileNames, inputFileName), `Expected fileName to be present in command line`);
|
||||
const { addOutput, getOutputs } = createAddOutput();
|
||||
if (commandLine.options.outFile || commandLine.options.out) {
|
||||
getSingleOutputFileNames(commandLine, addOutput);
|
||||
}
|
||||
else {
|
||||
getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput);
|
||||
}
|
||||
return getOutputs();
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
@@ -220,14 +252,14 @@ namespace ts {
|
||||
return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
|
||||
}
|
||||
}
|
||||
const buildInfoPath = getOutputPathForBuildInfo(configFile.options);
|
||||
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options);
|
||||
if (buildInfoPath) return buildInfoPath;
|
||||
return Debug.fail(`project ${configFile.options.configFilePath} expected to have at least one output`);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
|
||||
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile | undefined, { scriptTransformers, declarationTransformers }: EmitTransformers, emitOnlyDtsFiles?: boolean, onlyBuildInfo?: boolean): EmitResult {
|
||||
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile | undefined, { scriptTransformers, declarationTransformers }: EmitTransformers, emitOnlyDtsFiles?: boolean, onlyBuildInfo?: boolean, forceDtsEmit?: boolean): EmitResult {
|
||||
const compilerOptions = host.getCompilerOptions();
|
||||
const sourceMapDataList: SourceMapEmitResult[] | undefined = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
|
||||
const emittedFilesList: string[] | undefined = compilerOptions.listEmittedFiles ? [] : undefined;
|
||||
@@ -241,7 +273,14 @@ namespace ts {
|
||||
|
||||
// Emit each output file
|
||||
enter();
|
||||
forEachEmittedFile(host, emitSourceFileOrBundle, getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile);
|
||||
forEachEmittedFile(
|
||||
host,
|
||||
emitSourceFileOrBundle,
|
||||
getSourceFilesToEmit(host, targetSourceFile),
|
||||
forceDtsEmit,
|
||||
onlyBuildInfo,
|
||||
!targetSourceFile
|
||||
);
|
||||
exit();
|
||||
|
||||
|
||||
@@ -400,7 +439,7 @@ namespace ts {
|
||||
});
|
||||
const declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit;
|
||||
emitSkipped = emitSkipped || declBlocked;
|
||||
if (!declBlocked || emitOnlyDtsFiles) {
|
||||
if (!declBlocked || forceDtsEmit) {
|
||||
Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
|
||||
printSourceFileOrBundle(
|
||||
declarationFilePath,
|
||||
@@ -415,7 +454,7 @@ namespace ts {
|
||||
// Explicitly do not passthru either `inline` option
|
||||
}
|
||||
);
|
||||
if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === SyntaxKind.SourceFile) {
|
||||
if (forceDtsEmit && declarationTransform.transformed[0].kind === SyntaxKind.SourceFile) {
|
||||
const sourceFile = declarationTransform.transformed[0];
|
||||
exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
|
||||
}
|
||||
|
||||
@@ -770,7 +770,11 @@ namespace ts {
|
||||
fixupParentReferences(sourceFile);
|
||||
}
|
||||
|
||||
sourceFile.nodeCount = nodeCount;
|
||||
sourceFile.identifierCount = identifierCount;
|
||||
sourceFile.identifiers = identifiers;
|
||||
sourceFile.parseDiagnostics = parseDiagnostics;
|
||||
|
||||
const result = sourceFile as JsonSourceFile;
|
||||
clearState();
|
||||
return result;
|
||||
@@ -2121,7 +2125,7 @@ namespace ts {
|
||||
|
||||
// We didn't get a comma, and the list wasn't terminated, explicitly parse
|
||||
// out a comma so we give a good error message.
|
||||
parseExpected(SyntaxKind.CommaToken);
|
||||
parseExpected(SyntaxKind.CommaToken, getExpectedCommaDiagnostic(kind));
|
||||
|
||||
// If the token was a semicolon, and the caller allows that, then skip it and
|
||||
// continue. This ensures we get back on track and don't result in tons of
|
||||
@@ -2164,6 +2168,10 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getExpectedCommaDiagnostic(kind: ParsingContext) {
|
||||
return kind === ParsingContext.EnumMembers ? Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined;
|
||||
}
|
||||
|
||||
interface MissingList<T extends Node> extends NodeArray<T> {
|
||||
isMissingList: true;
|
||||
}
|
||||
|
||||
+16
-19
@@ -1530,18 +1530,18 @@ namespace ts {
|
||||
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false));
|
||||
}
|
||||
|
||||
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, transformers?: CustomTransformers): EmitResult {
|
||||
return runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers));
|
||||
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, transformers?: CustomTransformers, forceDtsEmit?: boolean): EmitResult {
|
||||
return runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit));
|
||||
}
|
||||
|
||||
function isEmitBlocked(emitFileName: string): boolean {
|
||||
return hasEmitBlockingDiagnostics.has(toPath(emitFileName));
|
||||
}
|
||||
|
||||
function emitWorker(program: Program, sourceFile: SourceFile | undefined, writeFileCallback: WriteFileCallback | undefined, cancellationToken: CancellationToken | undefined, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult {
|
||||
function emitWorker(program: Program, sourceFile: SourceFile | undefined, writeFileCallback: WriteFileCallback | undefined, cancellationToken: CancellationToken | undefined, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers, forceDtsEmit?: boolean): EmitResult {
|
||||
let declarationDiagnostics: readonly Diagnostic[] = [];
|
||||
|
||||
if (!emitOnlyDtsFiles) {
|
||||
if (!forceDtsEmit) {
|
||||
if (options.noEmit) {
|
||||
return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };
|
||||
}
|
||||
@@ -1590,6 +1590,8 @@ namespace ts {
|
||||
sourceFile,
|
||||
getTransformers(options, customTransformers, emitOnlyDtsFiles),
|
||||
emitOnlyDtsFiles,
|
||||
/*onlyBuildInfo*/ false,
|
||||
forceDtsEmit
|
||||
);
|
||||
|
||||
performance.mark("afterEmit");
|
||||
@@ -1757,13 +1759,12 @@ namespace ts {
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
if ((<ParameterDeclaration | PropertyDeclaration>parent).questionToken === node) {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
if ((<ParameterDeclaration | PropertyDeclaration | MethodDeclaration>parent).questionToken === node) {
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics._0_can_only_be_used_in_a_ts_file, "?"));
|
||||
return;
|
||||
}
|
||||
// falls through
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
// falls through
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
@@ -1833,7 +1834,6 @@ namespace ts {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
@@ -1841,7 +1841,7 @@ namespace ts {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
// Check type parameters
|
||||
if (nodes === (<ClassLikeDeclaration | FunctionLikeDeclaration>parent).typeParameters) {
|
||||
if (nodes === (<DeclarationWithTypeParameterChildren>parent).typeParameters) {
|
||||
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
|
||||
return;
|
||||
}
|
||||
@@ -1849,8 +1849,8 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.VariableStatement:
|
||||
// Check modifiers
|
||||
if (nodes === (<ClassDeclaration | FunctionLikeDeclaration | VariableStatement>parent).modifiers) {
|
||||
return checkModifiers(<NodeArray<Modifier>>nodes, parent.kind === SyntaxKind.VariableStatement);
|
||||
if (nodes === parent.modifiers) {
|
||||
return checkModifiers(parent.modifiers, parent.kind === SyntaxKind.VariableStatement);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
@@ -1876,8 +1876,9 @@ namespace ts {
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
// Check type arguments
|
||||
if (nodes === (<CallExpression | NewExpression | ExpressionWithTypeArguments | JsxOpeningLikeElement>parent).typeArguments) {
|
||||
if (nodes === (<NodeWithTypeArguments>parent).typeArguments) {
|
||||
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_arguments_can_only_be_used_in_a_ts_file));
|
||||
return;
|
||||
}
|
||||
@@ -2806,10 +2807,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (options.isolatedModules) {
|
||||
if (getEmitDeclarations(options)) {
|
||||
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules");
|
||||
}
|
||||
|
||||
if (options.out) {
|
||||
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules");
|
||||
}
|
||||
@@ -3107,7 +3104,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function verifyProjectReferences() {
|
||||
const buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? getOutputPathForBuildInfo(options) : undefined;
|
||||
const buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? getTsBuildInfoEmitOutputFilePath(options) : undefined;
|
||||
forEachProjectReference(projectReferences, resolvedProjectReferences, (resolvedRef, index, parent) => {
|
||||
const ref = (parent ? parent.commandLine.projectReferences : projectReferences)![index];
|
||||
const parentFile = parent && parent.sourceFile as JsonSourceFile;
|
||||
@@ -3134,7 +3131,7 @@ namespace ts {
|
||||
createDiagnosticForReference(parentFile, index, Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path);
|
||||
}
|
||||
}
|
||||
if (!parent && buildInfoPath && buildInfoPath === getOutputPathForBuildInfo(options)) {
|
||||
if (!parent && buildInfoPath && buildInfoPath === getTsBuildInfoEmitOutputFilePath(options)) {
|
||||
createDiagnosticForReference(parentFile, index, Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path);
|
||||
hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true);
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace ts {
|
||||
if (constructor && constructor.body) {
|
||||
let parameterPropertyDeclarationCount = 0;
|
||||
for (let i = indexOfFirstStatement; i < constructor.body.statements.length; i++) {
|
||||
if (isParameterPropertyDeclaration(getOriginalNode(constructor.body.statements[i]))) {
|
||||
if (isParameterPropertyDeclaration(getOriginalNode(constructor.body.statements[i]), constructor)) {
|
||||
parameterPropertyDeclarationCount++;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace ts {
|
||||
return getReturnTypeVisibilityError;
|
||||
}
|
||||
else if (isParameter(node)) {
|
||||
if (isParameterPropertyDeclaration(node) && hasModifier(node.parent, ModifierFlags.Private)) {
|
||||
if (isParameterPropertyDeclaration(node, node.parent) && hasModifier(node.parent, ModifierFlags.Private)) {
|
||||
return getVariableDeclarationTypeVisibilityError;
|
||||
}
|
||||
return getParameterDeclarationTypeVisibilityError;
|
||||
|
||||
@@ -895,7 +895,7 @@ namespace ts {
|
||||
const members: ClassElement[] = [];
|
||||
const constructor = getFirstConstructorWithBody(node);
|
||||
const parametersWithPropertyAssignments = constructor &&
|
||||
filter(constructor.parameters, isParameterPropertyDeclaration);
|
||||
filter(constructor.parameters, p => isParameterPropertyDeclaration(p, constructor));
|
||||
|
||||
if (parametersWithPropertyAssignments) {
|
||||
for (const parameter of parametersWithPropertyAssignments) {
|
||||
@@ -1907,7 +1907,7 @@ namespace ts {
|
||||
|
||||
function transformConstructorBody(body: Block, constructor: ConstructorDeclaration) {
|
||||
const parametersWithPropertyAssignments = constructor &&
|
||||
filter(constructor.parameters, isParameterPropertyDeclaration);
|
||||
filter(constructor.parameters, p => isParameterPropertyDeclaration(p, constructor));
|
||||
if (!some(parametersWithPropertyAssignments)) {
|
||||
return visitFunctionBody(body, visitor, context);
|
||||
}
|
||||
|
||||
@@ -308,6 +308,7 @@ namespace ts {
|
||||
/*@internal*/ getUpToDateStatusOfProject(project: string): UpToDateStatus;
|
||||
/*@internal*/ invalidateProject(configFilePath: ResolvedConfigFilePath, reloadLevel?: ConfigFileProgramReloadLevel): void;
|
||||
/*@internal*/ buildNextInvalidatedProject(): void;
|
||||
/*@internal*/ getAllParsedConfigs(): readonly ParsedCommandLine[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1620,7 +1621,7 @@ namespace ts {
|
||||
|
||||
if (!state.buildInfoChecked.has(resolvedPath)) {
|
||||
state.buildInfoChecked.set(resolvedPath, true);
|
||||
const buildInfoPath = getOutputPathForBuildInfo(project.options);
|
||||
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(project.options);
|
||||
if (buildInfoPath) {
|
||||
const value = state.readFileWithCache(buildInfoPath);
|
||||
const buildInfo = value && getBuildInfo(value);
|
||||
@@ -2047,6 +2048,10 @@ namespace ts {
|
||||
},
|
||||
invalidateProject: (configFilePath, reloadLevel) => invalidateProject(state, configFilePath, reloadLevel || ConfigFileProgramReloadLevel.None),
|
||||
buildNextInvalidatedProject: () => buildNextInvalidatedProject(state),
|
||||
getAllParsedConfigs: () => arrayFrom(mapDefinedIterator(
|
||||
state.configFileCache.values(),
|
||||
config => isParsedCommandLine(config) ? config : undefined
|
||||
)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3003,6 +3003,8 @@ namespace ts {
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult;
|
||||
/*@internal*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers, forceDtsEmit?: boolean): EmitResult; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
||||
@@ -3027,11 +3029,11 @@ namespace ts {
|
||||
|
||||
/* @internal */ getClassifiableNames(): UnderscoreEscapedMap<true>;
|
||||
|
||||
/* @internal */ getNodeCount(): number;
|
||||
/* @internal */ getIdentifierCount(): number;
|
||||
/* @internal */ getSymbolCount(): number;
|
||||
/* @internal */ getTypeCount(): number;
|
||||
/* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number };
|
||||
getNodeCount(): number;
|
||||
getIdentifierCount(): number;
|
||||
getSymbolCount(): number;
|
||||
getTypeCount(): number;
|
||||
getRelationCacheSizes(): { assignable: number, identity: number, subtype: number };
|
||||
|
||||
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
|
||||
/* @internal */ getResolvedTypeReferenceDirectives(): Map<ResolvedTypeReferenceDirective | undefined>;
|
||||
|
||||
@@ -975,6 +975,8 @@ namespace ts {
|
||||
return getSpanOfTokenAtPosition(sourceFile, node.pos);
|
||||
}
|
||||
|
||||
Debug.assert(!isJSDoc(errorNode));
|
||||
|
||||
const isMissing = nodeIsMissing(errorNode);
|
||||
const pos = isMissing || isJsxText(node)
|
||||
? errorNode.pos
|
||||
@@ -1007,7 +1009,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isDeclarationReadonly(declaration: Declaration): boolean {
|
||||
return !!(getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration));
|
||||
return !!(getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration, declaration.parent));
|
||||
}
|
||||
|
||||
export function isVarConst(node: VariableDeclaration | VariableDeclarationList): boolean {
|
||||
@@ -4981,8 +4983,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration, name: Identifier };
|
||||
export function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration {
|
||||
return hasModifier(node, ModifierFlags.ParameterPropertyModifier) && node.parent.kind === SyntaxKind.Constructor;
|
||||
export function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration {
|
||||
return hasModifier(node, ModifierFlags.ParameterPropertyModifier) && parent.kind === SyntaxKind.Constructor;
|
||||
}
|
||||
|
||||
export function isEmptyBindingPattern(node: BindingName): node is BindingPattern {
|
||||
|
||||
@@ -447,7 +447,7 @@ namespace ts {
|
||||
}
|
||||
export function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost) {
|
||||
if (compilerOptions.out || compilerOptions.outFile) return undefined;
|
||||
const buildInfoPath = getOutputPathForBuildInfo(compilerOptions);
|
||||
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(compilerOptions);
|
||||
if (!buildInfoPath) return undefined;
|
||||
const content = host.readFile(buildInfoPath);
|
||||
if (!content) return undefined;
|
||||
|
||||
+35
-14
@@ -32,6 +32,10 @@ namespace vfs {
|
||||
let devCount = 0; // A monotonically increasing count of device ids
|
||||
let inoCount = 0; // A monotonically increasing count of inodes
|
||||
|
||||
export interface DiffOptions {
|
||||
includeChangedFileWithSameContent?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a virtual POSIX-like file system.
|
||||
*/
|
||||
@@ -693,21 +697,25 @@ namespace vfs {
|
||||
* Generates a `FileSet` patch containing all the entries in this `FileSystem` that are not in `base`.
|
||||
* @param base The base file system. If not provided, this file system's `shadowRoot` is used (if present).
|
||||
*/
|
||||
public diff(base = this.shadowRoot) {
|
||||
public diff(base = this.shadowRoot, options: DiffOptions = {}) {
|
||||
const differences: FileSet = {};
|
||||
const hasDifferences = base ? FileSystem.rootDiff(differences, this, base) : FileSystem.trackCreatedInodes(differences, this, this._getRootLinks());
|
||||
const hasDifferences = base ?
|
||||
FileSystem.rootDiff(differences, this, base, options) :
|
||||
FileSystem.trackCreatedInodes(differences, this, this._getRootLinks());
|
||||
return hasDifferences ? differences : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a `FileSet` patch containing all the entries in `chagned` that are not in `base`.
|
||||
* Generates a `FileSet` patch containing all the entries in `changed` that are not in `base`.
|
||||
*/
|
||||
public static diff(changed: FileSystem, base: FileSystem) {
|
||||
public static diff(changed: FileSystem, base: FileSystem, options: DiffOptions = {}) {
|
||||
const differences: FileSet = {};
|
||||
return FileSystem.rootDiff(differences, changed, base) ? differences : undefined;
|
||||
return FileSystem.rootDiff(differences, changed, base, options) ?
|
||||
differences :
|
||||
undefined;
|
||||
}
|
||||
|
||||
private static diffWorker(container: FileSet, changed: FileSystem, changedLinks: ReadonlyMap<string, Inode> | undefined, base: FileSystem, baseLinks: ReadonlyMap<string, Inode> | undefined) {
|
||||
private static diffWorker(container: FileSet, changed: FileSystem, changedLinks: ReadonlyMap<string, Inode> | undefined, base: FileSystem, baseLinks: ReadonlyMap<string, Inode> | undefined, options: DiffOptions) {
|
||||
if (changedLinks && !baseLinks) return FileSystem.trackCreatedInodes(container, changed, changedLinks);
|
||||
if (baseLinks && !changedLinks) return FileSystem.trackDeletedInodes(container, baseLinks);
|
||||
if (changedLinks && baseLinks) {
|
||||
@@ -724,10 +732,10 @@ namespace vfs {
|
||||
const baseNode = baseLinks.get(basename);
|
||||
if (baseNode) {
|
||||
if (isDirectory(changedNode) && isDirectory(baseNode)) {
|
||||
return hasChanges = FileSystem.directoryDiff(container, basename, changed, changedNode, base, baseNode) || hasChanges;
|
||||
return hasChanges = FileSystem.directoryDiff(container, basename, changed, changedNode, base, baseNode, options) || hasChanges;
|
||||
}
|
||||
if (isFile(changedNode) && isFile(baseNode)) {
|
||||
return hasChanges = FileSystem.fileDiff(container, basename, changed, changedNode, base, baseNode) || hasChanges;
|
||||
return hasChanges = FileSystem.fileDiff(container, basename, changed, changedNode, base, baseNode, options) || hasChanges;
|
||||
}
|
||||
if (isSymlink(changedNode) && isSymlink(baseNode)) {
|
||||
return hasChanges = FileSystem.symlinkDiff(container, basename, changedNode, baseNode) || hasChanges;
|
||||
@@ -740,7 +748,7 @@ namespace vfs {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static rootDiff(container: FileSet, changed: FileSystem, base: FileSystem) {
|
||||
private static rootDiff(container: FileSet, changed: FileSystem, base: FileSystem, options: DiffOptions) {
|
||||
while (!changed._lazy.links && changed._shadowRoot) changed = changed._shadowRoot;
|
||||
while (!base._lazy.links && base._shadowRoot) base = base._shadowRoot;
|
||||
|
||||
@@ -750,10 +758,10 @@ namespace vfs {
|
||||
// no difference if the root links are empty and unshadowed
|
||||
if (!changed._lazy.links && !changed._shadowRoot && !base._lazy.links && !base._shadowRoot) return false;
|
||||
|
||||
return FileSystem.diffWorker(container, changed, changed._getRootLinks(), base, base._getRootLinks());
|
||||
return FileSystem.diffWorker(container, changed, changed._getRootLinks(), base, base._getRootLinks(), options);
|
||||
}
|
||||
|
||||
private static directoryDiff(container: FileSet, basename: string, changed: FileSystem, changedNode: DirectoryInode, base: FileSystem, baseNode: DirectoryInode) {
|
||||
private static directoryDiff(container: FileSet, basename: string, changed: FileSystem, changedNode: DirectoryInode, base: FileSystem, baseNode: DirectoryInode, options: DiffOptions) {
|
||||
while (!changedNode.links && changedNode.shadowRoot) changedNode = changedNode.shadowRoot;
|
||||
while (!baseNode.links && baseNode.shadowRoot) baseNode = baseNode.shadowRoot;
|
||||
|
||||
@@ -770,7 +778,7 @@ namespace vfs {
|
||||
|
||||
// no difference if both nodes have identical children
|
||||
const children: FileSet = {};
|
||||
if (!FileSystem.diffWorker(children, changed, changed._getLinks(changedNode), base, base._getLinks(baseNode))) {
|
||||
if (!FileSystem.diffWorker(children, changed, changed._getLinks(changedNode), base, base._getLinks(baseNode), options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -778,7 +786,7 @@ namespace vfs {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static fileDiff(container: FileSet, basename: string, changed: FileSystem, changedNode: FileInode, base: FileSystem, baseNode: FileInode) {
|
||||
private static fileDiff(container: FileSet, basename: string, changed: FileSystem, changedNode: FileInode, base: FileSystem, baseNode: FileInode, options: DiffOptions) {
|
||||
while (!changedNode.buffer && changedNode.shadowRoot) changedNode = changedNode.shadowRoot;
|
||||
while (!baseNode.buffer && baseNode.shadowRoot) baseNode = baseNode.shadowRoot;
|
||||
|
||||
@@ -800,7 +808,11 @@ namespace vfs {
|
||||
if (changedBuffer === baseBuffer) return false;
|
||||
|
||||
// no difference if both buffers are identical
|
||||
if (Buffer.compare(changedBuffer, baseBuffer) === 0) return false;
|
||||
if (Buffer.compare(changedBuffer, baseBuffer) === 0) {
|
||||
if (!options.includeChangedFileWithSameContent) return false;
|
||||
container[basename] = new SameFileContentFile(changedBuffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
container[basename] = new File(changedBuffer);
|
||||
return true;
|
||||
@@ -1361,6 +1373,12 @@ namespace vfs {
|
||||
}
|
||||
}
|
||||
|
||||
export class SameFileContentFile extends File {
|
||||
constructor(data: Buffer | string, metaAndEncoding?: { encoding?: string, meta?: Record<string, any> }) {
|
||||
super(data, metaAndEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
/** Extended options for a hard link in a `FileSet` */
|
||||
export class Link {
|
||||
public readonly path: string;
|
||||
@@ -1549,6 +1567,9 @@ namespace vfs {
|
||||
else if (entry instanceof Directory) {
|
||||
text += formatPatchWorker(file, entry.files);
|
||||
}
|
||||
else if (entry instanceof SameFileContentFile) {
|
||||
text += `//// [${file}] file written with same contents\r\n`;
|
||||
}
|
||||
else if (entry instanceof File) {
|
||||
const content = typeof entry.data === "string" ? entry.data : entry.data.toString("utf8");
|
||||
text += `//// [${file}]\r\n${content}\r\n\r\n`;
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...args: [] | [TNext | PromiseLike<TNext>]): Promise<IteratorResult<T, TReturn>>;
|
||||
next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
||||
throw(e: any): Promise<IteratorResult<T, TReturn>>;
|
||||
[Symbol.asyncIterator](): AsyncGenerator<T, TReturn, TNext>;
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ interface SymbolConstructor {
|
||||
|
||||
interface AsyncIterator<T, TReturn = any, TNext = undefined> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...args: [] | [TNext | PromiseLike<TNext>]): Promise<IteratorResult<T, TReturn>>;
|
||||
next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
||||
throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
const fixId = "fixConvertConstToLet";
|
||||
const errorCodes = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
||||
|
||||
registerCodeFix({
|
||||
errorCodes,
|
||||
getCodeActions: context => {
|
||||
const { sourceFile, span, program } = context;
|
||||
const variableStatement = getVariableStatement(sourceFile, span.start, program);
|
||||
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, variableStatement));
|
||||
return [createCodeFixAction(fixId, changes, Diagnostics.Convert_const_to_let, fixId, Diagnostics.Convert_const_to_let)];
|
||||
},
|
||||
fixIds: [fixId]
|
||||
});
|
||||
|
||||
function getVariableStatement(sourceFile: SourceFile, pos: number, program: Program) {
|
||||
const token = getTokenAtPosition(sourceFile, pos);
|
||||
const checker = program.getTypeChecker();
|
||||
const symbol = checker.getSymbolAtLocation(token);
|
||||
if (symbol) {
|
||||
return symbol.valueDeclaration.parent.parent as VariableStatement;
|
||||
}
|
||||
}
|
||||
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, variableStatement?: VariableStatement) {
|
||||
if (!variableStatement) {
|
||||
return;
|
||||
}
|
||||
const start = variableStatement.getStart();
|
||||
changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let");
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,14 @@ namespace ts.codefix {
|
||||
return [createCodeFixAction(fixId, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId, Diagnostics.Add_all_missing_async_modifiers)];
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const nodes = getNodes(diag.file, diag.start);
|
||||
if (!nodes) return;
|
||||
doChange(changes, context.sourceFile, nodes);
|
||||
}),
|
||||
getAllCodeActions: context => {
|
||||
const seen = createMap<true>();
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const nodes = getNodes(diag.file, diag.start);
|
||||
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore))) return;
|
||||
doChange(changes, context.sourceFile, nodes);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
function getReturnType(expr: FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
const fixId = "useBigintLiteral";
|
||||
const errorCodes = [
|
||||
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code,
|
||||
];
|
||||
|
||||
registerCodeFix({
|
||||
errorCodes,
|
||||
getCodeActions: context => {
|
||||
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span));
|
||||
if (changes.length > 0) {
|
||||
return [createCodeFixAction(fixId, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, Diagnostics.Convert_all_to_bigint_numeric_literals)];
|
||||
}
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => {
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag));
|
||||
},
|
||||
});
|
||||
|
||||
function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, span: TextSpan) {
|
||||
const numericLiteral = tryCast(getTokenAtPosition(sourceFile, span.start), isNumericLiteral);
|
||||
if (!numericLiteral) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298
|
||||
const newText = numericLiteral.getText(sourceFile) + "n";
|
||||
|
||||
changeTracker.replaceNode(sourceFile, numericLiteral, createBigIntLiteral(newText));
|
||||
}
|
||||
}
|
||||
@@ -1145,7 +1145,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
|
||||
export function eachSymbolReferenceInFile<T>(definition: Identifier, checker: TypeChecker, sourceFile: SourceFile, cb: (token: Identifier) => T): T | undefined {
|
||||
const symbol = isParameterPropertyDeclaration(definition.parent)
|
||||
const symbol = isParameterPropertyDeclaration(definition.parent, definition.parent.parent)
|
||||
? first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text))
|
||||
: checker.getSymbolAtLocation(definition);
|
||||
if (!symbol) return undefined;
|
||||
@@ -1886,7 +1886,7 @@ namespace ts.FindAllReferences.Core {
|
||||
const res = fromRoot(symbol);
|
||||
if (res) return res;
|
||||
|
||||
if (symbol.valueDeclaration && isParameterPropertyDeclaration(symbol.valueDeclaration)) {
|
||||
if (symbol.valueDeclaration && isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) {
|
||||
// For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property).
|
||||
const paramProps = checker.getSymbolsOfParameterPropertyDeclaration(cast(symbol.valueDeclaration, isParameter), symbol.name);
|
||||
Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & SymbolFlags.FunctionScopedVariable) && !!(paramProps[1].flags & SymbolFlags.Property)); // is [parameter, property]
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace ts.NavigationBar {
|
||||
curCancellationToken = cancellationToken;
|
||||
curSourceFile = sourceFile;
|
||||
try {
|
||||
return map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem);
|
||||
return map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem);
|
||||
}
|
||||
finally {
|
||||
reset();
|
||||
@@ -111,8 +111,8 @@ namespace ts.NavigationBar {
|
||||
return root;
|
||||
}
|
||||
|
||||
function addLeafNode(node: Node): void {
|
||||
pushChild(parent, emptyNavigationBarNode(node));
|
||||
function addLeafNode(node: Node, name?: DeclarationName): void {
|
||||
pushChild(parent, emptyNavigationBarNode(node, name));
|
||||
}
|
||||
|
||||
function emptyNavigationBarNode(node: Node, name?: DeclarationName): NavigationBarNode {
|
||||
@@ -197,7 +197,7 @@ namespace ts.NavigationBar {
|
||||
|
||||
// Parameter properties are children of the class, not the constructor.
|
||||
for (const param of ctr.parameters) {
|
||||
if (isParameterPropertyDeclaration(param)) {
|
||||
if (isParameterPropertyDeclaration(param, ctr)) {
|
||||
addLeafNode(param);
|
||||
}
|
||||
}
|
||||
@@ -243,23 +243,26 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
addNodeWithRecursiveChild(node, (<ShorthandPropertyAssignment>node).name);
|
||||
break;
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
const { expression } = <SpreadAssignment>node;
|
||||
// Use the expression as the name of the SpreadAssignment, otherwise show as <unknown>.
|
||||
isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node);
|
||||
break;
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
const { name, initializer } = <VariableDeclaration | BindingElement>node;
|
||||
const { name, initializer } = <VariableDeclaration | PropertyAssignment | BindingElement>node;
|
||||
if (isBindingPattern(name)) {
|
||||
addChildrenRecursively(name);
|
||||
}
|
||||
else if (initializer && isFunctionOrClassExpression(initializer)) {
|
||||
if (initializer.name) {
|
||||
// Don't add a node for the VariableDeclaration, just for the initializer.
|
||||
addChildrenRecursively(initializer);
|
||||
}
|
||||
else {
|
||||
// Add a node for the VariableDeclaration, but not for the initializer.
|
||||
startNode(node);
|
||||
forEachChild(initializer, addChildrenRecursively);
|
||||
endNode();
|
||||
}
|
||||
// Add a node for the VariableDeclaration, but not for the initializer.
|
||||
startNode(node);
|
||||
forEachChild(initializer, addChildrenRecursively);
|
||||
endNode();
|
||||
}
|
||||
else {
|
||||
addNodeWithRecursiveChild(node, initializer);
|
||||
@@ -699,12 +702,15 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
}
|
||||
|
||||
/** Flattens the NavNode tree to a list, keeping only the top-level items. */
|
||||
function topLevelItems(root: NavigationBarNode): NavigationBarNode[] {
|
||||
const topLevel: NavigationBarNode[] = [];
|
||||
/** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */
|
||||
function primaryNavBarMenuItems(root: NavigationBarNode): NavigationBarNode[] {
|
||||
// The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree.
|
||||
// The secondary (right) navbar menu displays the child items of whichever primary item is selected.
|
||||
// Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu.
|
||||
const primaryNavBarMenuItems: NavigationBarNode[] = [];
|
||||
function recur(item: NavigationBarNode) {
|
||||
if (isTopLevel(item)) {
|
||||
topLevel.push(item);
|
||||
if (shouldAppearInPrimaryNavBarMenu(item)) {
|
||||
primaryNavBarMenuItems.push(item);
|
||||
if (item.children) {
|
||||
for (const child of item.children) {
|
||||
recur(child);
|
||||
@@ -713,9 +719,16 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
}
|
||||
recur(root);
|
||||
return topLevel;
|
||||
return primaryNavBarMenuItems;
|
||||
|
||||
function isTopLevel(item: NavigationBarNode): boolean {
|
||||
/** Determines if a node should appear in the primary navbar menu. */
|
||||
function shouldAppearInPrimaryNavBarMenu(item: NavigationBarNode): boolean {
|
||||
// Items with children should always appear in the primary navbar menu.
|
||||
if (item.children) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Some nodes are otherwise important enough to always include in the primary navigation menu.
|
||||
switch (navigationBarNodeKind(item)) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
@@ -728,13 +741,6 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.JSDocCallbackTag:
|
||||
return true;
|
||||
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return hasSomeImportantChild(item);
|
||||
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
@@ -755,15 +761,9 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.Constructor:
|
||||
return true;
|
||||
default:
|
||||
return hasSomeImportantChild(item);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function hasSomeImportantChild(item: NavigationBarNode): boolean {
|
||||
return some(item.children, child => {
|
||||
const childKind = navigationBarNodeKind(child);
|
||||
return childKind !== SyntaxKind.VariableDeclaration && childKind !== SyntaxKind.BindingElement;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -778,19 +778,19 @@ namespace ts.NavigationBar {
|
||||
};
|
||||
}
|
||||
|
||||
function convertToTopLevelItem(n: NavigationBarNode): NavigationBarItem {
|
||||
function convertToPrimaryNavBarMenuItem(n: NavigationBarNode): NavigationBarItem {
|
||||
return {
|
||||
text: getItemName(n.node, n.name),
|
||||
kind: getNodeKind(n.node),
|
||||
kindModifiers: getModifiers(n.node),
|
||||
spans: getSpans(n),
|
||||
childItems: map(n.children, convertToChildItem) || emptyChildItemArray,
|
||||
childItems: map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray,
|
||||
indent: n.indent,
|
||||
bolded: false,
|
||||
grayed: false
|
||||
};
|
||||
|
||||
function convertToChildItem(n: NavigationBarNode): NavigationBarItem {
|
||||
function convertToSecondaryNavBarMenuItem(n: NavigationBarNode): NavigationBarItem {
|
||||
return {
|
||||
text: getItemName(n.node, n.name),
|
||||
kind: getNodeKind(n.node),
|
||||
|
||||
@@ -116,6 +116,7 @@ namespace ts.refactor.extractSymbol {
|
||||
export const cannotExtractRange: DiagnosticMessage = createMessage("Cannot extract range.");
|
||||
export const cannotExtractImport: DiagnosticMessage = createMessage("Cannot extract import statement.");
|
||||
export const cannotExtractSuper: DiagnosticMessage = createMessage("Cannot extract super call.");
|
||||
export const cannotExtractJSDoc: DiagnosticMessage = createMessage("Cannot extract JSDoc.");
|
||||
export const cannotExtractEmpty: DiagnosticMessage = createMessage("Cannot extract empty range.");
|
||||
export const expressionExpected: DiagnosticMessage = createMessage("expression expected.");
|
||||
export const uselessConstantType: DiagnosticMessage = createMessage("No reason to extract constant of type.");
|
||||
@@ -246,6 +247,10 @@ namespace ts.refactor.extractSymbol {
|
||||
return { targetRange: { range: statements, facts: rangeFacts, declarations } };
|
||||
}
|
||||
|
||||
if (isJSDoc(start)) {
|
||||
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
|
||||
}
|
||||
|
||||
if (isReturnStatement(start) && !start.expression) {
|
||||
// Makes no sense to extract an expression-less return statement.
|
||||
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
||||
@@ -1006,11 +1011,14 @@ namespace ts.refactor.extractSymbol {
|
||||
const localNameText = getUniqueName(isClassLike(scope) ? "newProperty" : "newLocal", file);
|
||||
const isJS = isInJSFile(scope);
|
||||
|
||||
const variableType = isJS || !checker.isContextSensitive(node)
|
||||
let variableType = isJS || !checker.isContextSensitive(node)
|
||||
? undefined
|
||||
: checker.typeToTypeNode(checker.getContextualType(node)!, scope, NodeBuilderFlags.NoTruncation); // TODO: GH#18217
|
||||
|
||||
const initializer = transformConstantInitializer(node, substitutions);
|
||||
let initializer = transformConstantInitializer(node, substitutions);
|
||||
|
||||
({ variableType, initializer } = transformFunctionInitializerAndType(variableType, initializer));
|
||||
|
||||
suppressLeadingAndTrailingTrivia(initializer);
|
||||
|
||||
const changeTracker = textChanges.ChangeTracker.fromContext(context);
|
||||
@@ -1102,6 +1110,73 @@ namespace ts.refactor.extractSymbol {
|
||||
const renameFilename = node.getSourceFile().fileName;
|
||||
const renameLocation = getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true);
|
||||
return { renameFilename, renameLocation, edits };
|
||||
|
||||
function transformFunctionInitializerAndType(variableType: TypeNode | undefined, initializer: Expression): { variableType: TypeNode | undefined, initializer: Expression } {
|
||||
// If no contextual type exists there is nothing to transfer to the function signature
|
||||
if (variableType === undefined) return { variableType, initializer };
|
||||
// Only do this for function expressions and arrow functions that are not generic
|
||||
if (!isFunctionExpression(initializer) && !isArrowFunction(initializer) || !!initializer.typeParameters) return { variableType, initializer };
|
||||
const functionType = checker.getTypeAtLocation(node);
|
||||
const functionSignature = singleOrUndefined(checker.getSignaturesOfType(functionType, SignatureKind.Call));
|
||||
|
||||
// If no function signature, maybe there was an error, do nothing
|
||||
if (!functionSignature) return { variableType, initializer };
|
||||
// If the function signature has generic type parameters we don't attempt to move the parameters
|
||||
if (!!functionSignature.getTypeParameters()) return { variableType, initializer };
|
||||
|
||||
// We add parameter types if needed
|
||||
const parameters: ParameterDeclaration[] = [];
|
||||
let hasAny = false;
|
||||
for (const p of initializer.parameters) {
|
||||
if (p.type) {
|
||||
parameters.push(p);
|
||||
}
|
||||
else {
|
||||
const paramType = checker.getTypeAtLocation(p);
|
||||
if (paramType === checker.getAnyType()) hasAny = true;
|
||||
|
||||
parameters.push(updateParameter(p,
|
||||
p.decorators, p.modifiers, p.dotDotDotToken,
|
||||
p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, NodeBuilderFlags.NoTruncation), p.initializer));
|
||||
}
|
||||
}
|
||||
// If a parameter was inferred as any we skip adding function parameters at all.
|
||||
// Turning an implicit any (which under common settings is a error) to an explicit
|
||||
// is probably actually a worse refactor outcome.
|
||||
if (hasAny) return { variableType, initializer };
|
||||
variableType = undefined;
|
||||
if (isArrowFunction(initializer)) {
|
||||
initializer = updateArrowFunction(initializer, node.modifiers, initializer.typeParameters,
|
||||
parameters,
|
||||
initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, NodeBuilderFlags.NoTruncation),
|
||||
initializer.equalsGreaterThanToken,
|
||||
initializer.body);
|
||||
}
|
||||
else {
|
||||
if (functionSignature && !!functionSignature.thisParameter) {
|
||||
const firstParameter = firstOrUndefined(parameters);
|
||||
// If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it
|
||||
// Note: If this parameter was already there, it would have been previously updated with the type if not type was present
|
||||
if ((!firstParameter || (isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) {
|
||||
const thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node);
|
||||
parameters.splice(0, 0, createParameter(
|
||||
/* decorators */ undefined,
|
||||
/* modifiers */ undefined,
|
||||
/* dotDotDotToken */ undefined,
|
||||
"this",
|
||||
/* questionToken */ undefined,
|
||||
checker.typeToTypeNode(thisType, scope, NodeBuilderFlags.NoTruncation)
|
||||
));
|
||||
}
|
||||
}
|
||||
initializer = updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken,
|
||||
initializer.name, initializer.typeParameters,
|
||||
parameters,
|
||||
initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, NodeBuilderFlags.NoTruncation),
|
||||
initializer.body);
|
||||
}
|
||||
return { variableType, initializer };
|
||||
}
|
||||
}
|
||||
|
||||
function getContainingVariableDeclarationIfInList(node: Node, scope: Scope) {
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
|
||||
}
|
||||
|
||||
function isAcceptedDeclaration(node: Node): node is AcceptedDeclaration {
|
||||
return isParameterPropertyDeclaration(node) || isPropertyDeclaration(node) || isPropertyAssignment(node);
|
||||
return isParameterPropertyDeclaration(node, node.parent) || isPropertyDeclaration(node) || isPropertyAssignment(node);
|
||||
}
|
||||
|
||||
function createPropertyName (name: string, originalName: AcceptedNameType) {
|
||||
@@ -214,7 +214,7 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
|
||||
}
|
||||
|
||||
function insertAccessor(changeTracker: textChanges.ChangeTracker, file: SourceFile, accessor: AccessorDeclaration, declaration: AcceptedDeclaration, container: ContainerDeclaration) {
|
||||
isParameterPropertyDeclaration(declaration) ? changeTracker.insertNodeAtClassStart(file, <ClassLikeDeclaration>container, accessor) :
|
||||
isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, <ClassLikeDeclaration>container, accessor) :
|
||||
isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) :
|
||||
changeTracker.insertNodeAfter(file, declaration, accessor);
|
||||
}
|
||||
|
||||
@@ -79,9 +79,11 @@
|
||||
"codefixes/fixStrictClassInitialization.ts",
|
||||
"codefixes/requireInTs.ts",
|
||||
"codefixes/useDefaultImport.ts",
|
||||
"codefixes/useBigintLiteral.ts",
|
||||
"codefixes/fixAddModuleReferTypeMissingTypeof.ts",
|
||||
"codefixes/convertToMappedObjectType.ts",
|
||||
"codefixes/removeUnnecessaryAwait.ts",
|
||||
"codefixes/convertConstToLet.ts",
|
||||
"refactors/convertExport.ts",
|
||||
"refactors/convertImport.ts",
|
||||
"refactors/extractSymbol.ts",
|
||||
|
||||
@@ -353,8 +353,13 @@ namespace ts {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
return ScriptElementKind.memberFunctionElement;
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
const {initializer} = node as PropertyAssignment;
|
||||
return isFunctionLike(initializer) ? ScriptElementKind.memberFunctionElement : ScriptElementKind.memberVariableElement;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
case SyntaxKind.IndexSignature: return ScriptElementKind.indexSignatureElement;
|
||||
case SyntaxKind.ConstructSignature: return ScriptElementKind.constructSignatureElement;
|
||||
|
||||
@@ -10,6 +10,7 @@ interface ExecResult {
|
||||
|
||||
interface UserConfig {
|
||||
types: string[];
|
||||
cloneUrl: string;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
@@ -49,13 +50,17 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
|
||||
const stdio = isWorker ? "pipe" : "inherit";
|
||||
let types: string[] | undefined;
|
||||
if (fs.existsSync(path.join(cwd, "test.json"))) {
|
||||
const submoduleDir = path.join(cwd, directoryName);
|
||||
exec("git", ["reset", "HEAD", "--hard"], { cwd: submoduleDir });
|
||||
exec("git", ["clean", "-f"], { cwd: submoduleDir });
|
||||
exec("git", ["submodule", "update", "--init", "--remote", "."], { cwd: originalCwd });
|
||||
|
||||
const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig;
|
||||
ts.Debug.assert(!!config.types, "Bad format from test.json: Types field must be present.");
|
||||
ts.Debug.assert(!!config.cloneUrl, "Bad format from test.json: cloneUrl field must be present.");
|
||||
const submoduleDir = path.join(cwd, directoryName);
|
||||
if (!fs.existsSync(submoduleDir)) {
|
||||
exec("git", ["clone", config.cloneUrl, directoryName], { cwd });
|
||||
}
|
||||
exec("git", ["reset", "HEAD", "--hard"], { cwd: submoduleDir });
|
||||
exec("git", ["clean", "-f"], { cwd: submoduleDir });
|
||||
exec("git", ["pull", "-f"], { cwd: submoduleDir });
|
||||
|
||||
types = config.types;
|
||||
|
||||
cwd = config.path ? path.join(cwd, config.path) : submoduleDir;
|
||||
|
||||
@@ -160,4 +160,22 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
describe("unittests:: Program.getNodeCount / Program.getIdentifierCount", () => {
|
||||
it("works on projects that have .json files", () => {
|
||||
const main = new documents.TextDocument("/main.ts", 'export { version } from "./package.json";');
|
||||
const pkg = new documents.TextDocument("/package.json", '{"version": "1.0.0"}');
|
||||
|
||||
const fs = vfs.createFromFileSystem(Harness.IO, /*ignoreCase*/ false, { documents: [main, pkg], cwd: "/" });
|
||||
const program = createProgram(["/main.ts"], { resolveJsonModule: true }, new fakes.CompilerHost(fs, { newLine: NewLineKind.LineFeed }));
|
||||
|
||||
const json = program.getSourceFile("/package.json")!;
|
||||
assert.equal(json.scriptKind, ScriptKind.JSON);
|
||||
assert.isNumber(json.nodeCount);
|
||||
assert.isNumber(json.identifierCount);
|
||||
|
||||
assert.isNotNaN(program.getNodeCount());
|
||||
assert.isNotNaN(program.getIdentifierCount());
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -380,6 +380,10 @@ switch (x) {
|
||||
`[#|{ 1;|] }`,
|
||||
[refactor.extractSymbol.Messages.cannotExtractRange.message]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed19",
|
||||
`[#|/** @type {number} */|] const foo = 1;`,
|
||||
[refactor.extractSymbol.Messages.cannotExtractJSDoc.message]);
|
||||
|
||||
testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, [refactor.extractSymbol.Messages.cannotExtractIdentifier.message]);
|
||||
});
|
||||
}
|
||||
@@ -300,6 +300,34 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/33295
|
||||
testBaseline("transformParameterProperty", () => {
|
||||
return transpileModule("", {
|
||||
transformers: {
|
||||
before: [transformAddParameterProperty],
|
||||
},
|
||||
compilerOptions: {
|
||||
target: ScriptTarget.ES5,
|
||||
newLine: NewLineKind.CarriageReturnLineFeed,
|
||||
}
|
||||
}).outputText;
|
||||
|
||||
function transformAddParameterProperty(_context: TransformationContext) {
|
||||
return (sourceFile: SourceFile): SourceFile => {
|
||||
return visitNode(sourceFile);
|
||||
};
|
||||
function visitNode(sf: SourceFile) {
|
||||
// produce `class Foo { constructor(@Dec private x) {} }`;
|
||||
// The decorator is required to trigger ts.ts transformations.
|
||||
const classDecl = createClassDeclaration([], [], "Foo", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [
|
||||
createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, [
|
||||
createParameter(/*decorators*/ [createDecorator(createIdentifier("Dec"))], /*modifiers*/ [createModifier(SyntaxKind.PrivateKeyword)], /*dotDotDotToken*/ undefined, "x")], createBlock([]))
|
||||
]);
|
||||
return updateSourceFileNode(sf, [classDecl]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function baselineDeclarationTransform(text: string, opts: TranspileOptions) {
|
||||
const fs = vfs.createFromFileSystem(Harness.IO, /*caseSensitive*/ true, { documents: [new documents.TextDocument("/.src/index.ts", text)] });
|
||||
const host = new fakes.CompilerHost(fs, opts.compilerOptions);
|
||||
@@ -389,7 +417,7 @@ class Clazz {
|
||||
}
|
||||
`, {
|
||||
transformers: {
|
||||
before: [addSyntheticComment(n => isPropertyDeclaration(n) || isParameterPropertyDeclaration(n) || isClassDeclaration(n) || isConstructorDeclaration(n))],
|
||||
before: [addSyntheticComment(n => isPropertyDeclaration(n) || isParameterPropertyDeclaration(n, n.parent) || isClassDeclaration(n) || isConstructorDeclaration(n))],
|
||||
},
|
||||
compilerOptions: {
|
||||
target: ScriptTarget.ES2015,
|
||||
|
||||
@@ -2,26 +2,8 @@ namespace ts {
|
||||
describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
|
||||
let outFileFs: vfs.FileSystem;
|
||||
const { time, tick } = getTime();
|
||||
const enum ext { js, jsmap, dts, dtsmap, buildinfo }
|
||||
const enum project { lib, app }
|
||||
type OutputFile = [string, string, string, string, string];
|
||||
function relName(path: string) { return path.slice(1); }
|
||||
const outputFiles: [OutputFile, OutputFile] = [
|
||||
[
|
||||
"/src/lib/module.js",
|
||||
"/src/lib/module.js.map",
|
||||
"/src/lib/module.d.ts",
|
||||
"/src/lib/module.d.ts.map",
|
||||
"/src/lib/module.tsbuildinfo"
|
||||
],
|
||||
[
|
||||
"/src/app/module.js",
|
||||
"/src/app/module.js.map",
|
||||
"/src/app/module.d.ts",
|
||||
"/src/app/module.d.ts.map",
|
||||
"/src/app/module.tsbuildinfo"
|
||||
]
|
||||
];
|
||||
type Sources = [string, readonly string[]];
|
||||
const enum source { config, ts }
|
||||
const sources: [Sources, Sources] = [
|
||||
@@ -67,17 +49,7 @@ namespace ts {
|
||||
tick,
|
||||
proj: "amdModulesWithOut",
|
||||
rootNames: ["/src/app"],
|
||||
expectedMapFileNames: [
|
||||
outputFiles[project.lib][ext.jsmap],
|
||||
outputFiles[project.lib][ext.dtsmap],
|
||||
outputFiles[project.app][ext.jsmap],
|
||||
outputFiles[project.app][ext.dtsmap],
|
||||
],
|
||||
expectedBuildInfoFilesForSectionBaselines: [
|
||||
[outputFiles[project.lib][ext.buildinfo], outputFiles[project.lib][ext.js], outputFiles[project.lib][ext.dts]],
|
||||
[outputFiles[project.app][ext.buildinfo], outputFiles[project.app][ext.js], outputFiles[project.app][ext.dts]]
|
||||
],
|
||||
lastProjectOutput: outputFiles[project.app][ext.js],
|
||||
baselineSourceMap: true,
|
||||
initialBuild: {
|
||||
modifyFs
|
||||
},
|
||||
@@ -87,10 +59,6 @@ namespace ts {
|
||||
incrementalHeaderChangedBuild: modifyAgainFs ? {
|
||||
modifyFs: modifyAgainFs
|
||||
} : undefined,
|
||||
outputFiles: [
|
||||
...outputFiles[project.lib],
|
||||
...outputFiles[project.app]
|
||||
],
|
||||
baselineOnly: true
|
||||
});
|
||||
}
|
||||
@@ -207,13 +175,6 @@ ${internal} export enum internalEnum { a, b, c }`);
|
||||
replaceText(fs, sources[project.app][source.ts][0], "file1", "lib/file1");
|
||||
}
|
||||
|
||||
const libOutputFile: OutputFile = [
|
||||
"/src/lib/module.js",
|
||||
"/src/lib/module.js.map",
|
||||
"/src/lib/module.d.ts",
|
||||
"/src/lib/module.d.ts.map",
|
||||
"/src/lib/module.tsbuildinfo"
|
||||
];
|
||||
verifyTsbuildOutput({
|
||||
scenario: "when the module resolution finds original source file",
|
||||
projFs: () => outFileFs,
|
||||
@@ -221,17 +182,7 @@ ${internal} export enum internalEnum { a, b, c }`);
|
||||
tick,
|
||||
proj: "amdModulesWithOut",
|
||||
rootNames: ["/src/app"],
|
||||
expectedMapFileNames: [
|
||||
libOutputFile[ext.jsmap],
|
||||
libOutputFile[ext.dtsmap],
|
||||
outputFiles[project.app][ext.jsmap],
|
||||
outputFiles[project.app][ext.dtsmap],
|
||||
],
|
||||
expectedBuildInfoFilesForSectionBaselines: [
|
||||
[libOutputFile[ext.buildinfo], libOutputFile[ext.js], libOutputFile[ext.dts]],
|
||||
[outputFiles[project.app][ext.buildinfo], outputFiles[project.app][ext.js], outputFiles[project.app][ext.dts]]
|
||||
],
|
||||
lastProjectOutput: outputFiles[project.app][ext.js],
|
||||
baselineSourceMap: true,
|
||||
initialBuild: {
|
||||
modifyFs,
|
||||
expectedDiagnostics: [
|
||||
@@ -242,10 +193,6 @@ ${internal} export enum internalEnum { a, b, c }`);
|
||||
[Diagnostics.Building_project_0, sources[project.app][source.config]],
|
||||
]
|
||||
},
|
||||
outputFiles: [
|
||||
...libOutputFile,
|
||||
...outputFiles[project.app]
|
||||
],
|
||||
baselineOnly: true,
|
||||
verifyDiagnostics: true
|
||||
});
|
||||
|
||||
@@ -17,20 +17,6 @@ namespace ts {
|
||||
tick,
|
||||
proj: "emitDeclarationOnly",
|
||||
rootNames: ["/src"],
|
||||
lastProjectOutput: `/src/lib/index.d.ts`,
|
||||
outputFiles: [
|
||||
"/src/lib/a.d.ts",
|
||||
"/src/lib/b.d.ts",
|
||||
"/src/lib/c.d.ts",
|
||||
"/src/lib/index.d.ts",
|
||||
"/src/tsconfig.tsbuildinfo",
|
||||
...(disableMap ? emptyArray : [
|
||||
"/src/lib/a.d.ts.map",
|
||||
"/src/lib/b.d.ts.map",
|
||||
"/src/lib/c.d.ts.map",
|
||||
"/src/lib/index.d.ts.map"
|
||||
])
|
||||
],
|
||||
initialBuild: {
|
||||
modifyFs: disableMap ?
|
||||
(fs => replaceText(fs, "/src/tsconfig.json", `"declarationMap": true,`, "")) :
|
||||
@@ -63,16 +49,6 @@ namespace ts {
|
||||
tick,
|
||||
proj: "emitDeclarationOnly",
|
||||
rootNames: ["/src"],
|
||||
lastProjectOutput: `/src/lib/a.d.ts`,
|
||||
outputFiles: [
|
||||
"/src/lib/a.d.ts",
|
||||
"/src/lib/b.d.ts",
|
||||
"/src/lib/c.d.ts",
|
||||
"/src/tsconfig.tsbuildinfo",
|
||||
"/src/lib/a.d.ts.map",
|
||||
"/src/lib/b.d.ts.map",
|
||||
"/src/lib/c.d.ts.map",
|
||||
],
|
||||
initialBuild: {
|
||||
modifyFs: fs => {
|
||||
fs.rimrafSync("/src/src/index.ts");
|
||||
|
||||
@@ -164,9 +164,10 @@ interface Symbol {
|
||||
}
|
||||
}
|
||||
|
||||
function generateSourceMapBaselineFiles(fs: vfs.FileSystem, mapFileNames: readonly string[]) {
|
||||
for (const mapFile of mapFileNames) {
|
||||
if (!fs.existsSync(mapFile)) continue;
|
||||
function generateSourceMapBaselineFiles(fs: vfs.FileSystem, mapFileNames: Iterator<string>) {
|
||||
while (true) {
|
||||
const { value: mapFile, done } = mapFileNames.next();
|
||||
if (done) break;
|
||||
const text = Harness.SourceMapRecorder.getSourceMapRecordWithVFS(fs, mapFile);
|
||||
fs.writeFileSync(`${mapFile}.baseline.txt`, text);
|
||||
}
|
||||
@@ -229,21 +230,28 @@ interface Symbol {
|
||||
}
|
||||
}
|
||||
|
||||
interface BuildInput {
|
||||
export interface BuildInput {
|
||||
fs: vfs.FileSystem;
|
||||
tick: () => void;
|
||||
rootNames: readonly string[];
|
||||
expectedMapFileNames?: readonly string[];
|
||||
expectedBuildInfoFilesForSectionBaselines?: readonly BuildInfoSectionBaselineFiles[];
|
||||
modifyFs: (fs: vfs.FileSystem) => void;
|
||||
baselineSourceMap?: true;
|
||||
baselineBuildInfo?: true;
|
||||
}
|
||||
|
||||
function build({ fs, tick, rootNames, expectedMapFileNames, expectedBuildInfoFilesForSectionBaselines, modifyFs }: BuildInput) {
|
||||
export function tscBuild({ fs, tick, rootNames, modifyFs, baselineSourceMap, baselineBuildInfo }: BuildInput) {
|
||||
const actualReadFileMap = createMap<number>();
|
||||
modifyFs(fs);
|
||||
tick();
|
||||
|
||||
const host = new fakes.SolutionBuilderHost(fs);
|
||||
const writtenFiles = createMap<true>();
|
||||
const originalWriteFile = host.writeFile;
|
||||
host.writeFile = (fileName, content, writeByteOrderMark) => {
|
||||
assert.isFalse(writtenFiles.has(fileName));
|
||||
writtenFiles.set(fileName, true);
|
||||
return originalWriteFile.call(host, fileName, content, writeByteOrderMark);
|
||||
};
|
||||
const builder = createSolutionBuilder(host, rootNames, { dry: false, force: false, verbose: true });
|
||||
host.clearDiagnostics();
|
||||
const originalReadFile = host.readFile;
|
||||
@@ -255,14 +263,28 @@ interface Symbol {
|
||||
return originalReadFile.call(host, path);
|
||||
};
|
||||
builder.build();
|
||||
if (expectedMapFileNames) generateSourceMapBaselineFiles(fs, expectedMapFileNames);
|
||||
generateBuildInfoSectionBaselineFiles(fs, expectedBuildInfoFilesForSectionBaselines || emptyArray);
|
||||
if (baselineSourceMap) generateSourceMapBaselineFiles(fs, mapDefinedIterator(writtenFiles.keys(), f => f.endsWith(".map") ? f : undefined));
|
||||
if (baselineBuildInfo) {
|
||||
let expectedBuildInfoFiles: BuildInfoSectionBaselineFiles[] | undefined;
|
||||
for (const { options } of builder.getAllParsedConfigs()) {
|
||||
const out = options.outFile || options.out;
|
||||
if (out) {
|
||||
const { jsFilePath, declarationFilePath, buildInfoPath } = getOutputPathsForBundle(options, /*forceDts*/ false);
|
||||
if (buildInfoPath && writtenFiles.has(buildInfoPath)) {
|
||||
(expectedBuildInfoFiles || (expectedBuildInfoFiles = [])).push(
|
||||
[buildInfoPath, jsFilePath, declarationFilePath]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expectedBuildInfoFiles) generateBuildInfoSectionBaselineFiles(fs, expectedBuildInfoFiles);
|
||||
}
|
||||
fs.makeReadonly();
|
||||
return { fs, actualReadFileMap, host, builder };
|
||||
return { fs, actualReadFileMap, host, builder, writtenFiles };
|
||||
}
|
||||
|
||||
function generateBaseline(fs: vfs.FileSystem, proj: string, scenario: string, subScenario: string, baseFs: vfs.FileSystem) {
|
||||
const patch = fs.diff(baseFs);
|
||||
const patch = fs.diff(baseFs, { includeChangedFileWithSameContent: true });
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
Harness.Baseline.runBaseline(`tsbuild/${proj}/${subScenario.split(" ").join("-")}/${scenario.split(" ").join("-")}.js`, patch ? vfs.formatPatch(patch) : null);
|
||||
}
|
||||
@@ -301,22 +323,18 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
|
||||
tick: () => void;
|
||||
proj: string;
|
||||
rootNames: readonly string[];
|
||||
/** map file names to generate baseline of */
|
||||
expectedMapFileNames?: readonly string[];
|
||||
expectedBuildInfoFilesForSectionBaselines?: readonly BuildInfoSectionBaselineFiles[];
|
||||
lastProjectOutput: string;
|
||||
initialBuild: BuildState;
|
||||
outputFiles?: readonly string[];
|
||||
incrementalDtsChangedBuild?: BuildState;
|
||||
incrementalDtsUnchangedBuild?: BuildState;
|
||||
incrementalHeaderChangedBuild?: BuildState;
|
||||
baselineOnly?: true;
|
||||
verifyDiagnostics?: true;
|
||||
baselineSourceMap?: true;
|
||||
}
|
||||
|
||||
export function verifyTsbuildOutput({
|
||||
scenario, projFs, time, tick, proj, rootNames, outputFiles, baselineOnly, verifyDiagnostics,
|
||||
expectedMapFileNames, expectedBuildInfoFilesForSectionBaselines, lastProjectOutput,
|
||||
scenario, projFs, time, tick, proj, rootNames,
|
||||
baselineOnly, verifyDiagnostics, baselineSourceMap,
|
||||
initialBuild, incrementalDtsChangedBuild, incrementalDtsUnchangedBuild, incrementalHeaderChangedBuild
|
||||
}: VerifyTsBuildInput) {
|
||||
describe(`tsc --b ${proj}:: ${scenario}`, () => {
|
||||
@@ -324,22 +342,24 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
|
||||
let actualReadFileMap: Map<number>;
|
||||
let firstBuildTime: number;
|
||||
let host: fakes.SolutionBuilderHost;
|
||||
let initialWrittenFiles: Map<true>;
|
||||
before(() => {
|
||||
const result = build({
|
||||
const result = tscBuild({
|
||||
fs: projFs().shadow(),
|
||||
tick,
|
||||
rootNames,
|
||||
expectedMapFileNames,
|
||||
expectedBuildInfoFilesForSectionBaselines,
|
||||
modifyFs: initialBuild.modifyFs,
|
||||
baselineSourceMap,
|
||||
baselineBuildInfo: true,
|
||||
});
|
||||
({ fs, actualReadFileMap, host } = result);
|
||||
({ fs, actualReadFileMap, host, writtenFiles: initialWrittenFiles } = result);
|
||||
firstBuildTime = time();
|
||||
});
|
||||
after(() => {
|
||||
fs = undefined!;
|
||||
actualReadFileMap = undefined!;
|
||||
host = undefined!;
|
||||
initialWrittenFiles = undefined!;
|
||||
});
|
||||
describe("initialBuild", () => {
|
||||
if (!baselineOnly || verifyDiagnostics) {
|
||||
@@ -365,17 +385,18 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
|
||||
let beforeBuildTime: number;
|
||||
let afterBuildTime: number;
|
||||
before(() => {
|
||||
const lastProjectOutput = last(arrayFrom(initialWrittenFiles.keys()));
|
||||
beforeBuildTime = fs.statSync(lastProjectOutput).mtimeMs;
|
||||
tick();
|
||||
newFs = fs.shadow();
|
||||
tick();
|
||||
({ actualReadFileMap, host } = build({
|
||||
({ actualReadFileMap, host } = tscBuild({
|
||||
fs: newFs,
|
||||
tick,
|
||||
rootNames,
|
||||
expectedMapFileNames,
|
||||
expectedBuildInfoFilesForSectionBaselines,
|
||||
modifyFs: incrementalModifyFs,
|
||||
baselineSourceMap,
|
||||
baselineBuildInfo: true,
|
||||
}));
|
||||
afterBuildTime = newFs.statSync(lastProjectOutput).mtimeMs;
|
||||
});
|
||||
@@ -408,22 +429,19 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
|
||||
});
|
||||
}
|
||||
it(`Verify emit output file text is same when built clean`, () => {
|
||||
const expectedOutputFiles = Debug.assertDefined(outputFiles);
|
||||
const { fs } = build({
|
||||
const { fs, writtenFiles } = tscBuild({
|
||||
fs: newFs.shadow(),
|
||||
tick,
|
||||
rootNames,
|
||||
modifyFs: fs => {
|
||||
// Delete output files
|
||||
for (const outputFile of expectedOutputFiles) {
|
||||
if (fs.existsSync(outputFile)) {
|
||||
fs.rimrafSync(outputFile);
|
||||
}
|
||||
}
|
||||
const host = new fakes.SolutionBuilderHost(fs);
|
||||
const builder = createSolutionBuilder(host, rootNames, { clean: true });
|
||||
builder.clean();
|
||||
},
|
||||
});
|
||||
|
||||
for (const outputFile of expectedOutputFiles) {
|
||||
for (const outputFile of arrayFrom(writtenFiles.keys())) {
|
||||
const expectedText = fs.existsSync(outputFile) ? fs.readFileSync(outputFile, "utf8") : undefined;
|
||||
const actualText = newFs.existsSync(outputFile) ? newFs.readFileSync(outputFile, "utf8") : undefined;
|
||||
assert.equal(actualText, expectedText, `File: ${outputFile}`);
|
||||
|
||||
@@ -16,14 +16,6 @@ namespace ts {
|
||||
tick,
|
||||
proj: "inferredTypeFromTransitiveModule",
|
||||
rootNames: ["/src"],
|
||||
lastProjectOutput: `/src/obj/index.js`,
|
||||
outputFiles: [
|
||||
"/src/obj/bar.js", "/src/obj/bar.d.ts",
|
||||
"/src/obj/bundling.js", "/src/obj/bundling.d.ts",
|
||||
"/src/obj/lazyIndex.js", "/src/obj/lazyIndex.d.ts",
|
||||
"/src/obj/index.js", "/src/obj/index.d.ts",
|
||||
"/src/obj/tsconfig.tsbuildinfo"
|
||||
],
|
||||
initialBuild: {
|
||||
modifyFs: noop,
|
||||
expectedDiagnostics: [
|
||||
@@ -33,7 +25,7 @@ namespace ts {
|
||||
]
|
||||
},
|
||||
incrementalDtsChangedBuild: {
|
||||
modifyFs: fs => replaceText(fs, "/src/bar.ts", "param: string", ""),
|
||||
modifyFs: changeBarParam,
|
||||
expectedDiagnostics: [
|
||||
getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/obj/bar.js", "src/bar.ts"],
|
||||
@@ -44,5 +36,55 @@ namespace ts {
|
||||
baselineOnly: true,
|
||||
verifyDiagnostics: true
|
||||
});
|
||||
|
||||
verifyTsbuildOutput({
|
||||
scenario: "inferred type from transitive module with isolatedModules",
|
||||
projFs: () => projFs,
|
||||
time,
|
||||
tick,
|
||||
proj: "inferredTypeFromTransitiveModule",
|
||||
rootNames: ["/src"],
|
||||
initialBuild: { modifyFs: changeToIsolatedModules },
|
||||
incrementalDtsChangedBuild: { modifyFs: changeBarParam },
|
||||
baselineOnly: true,
|
||||
});
|
||||
|
||||
it("reports errors in files affected by change in signature", () => {
|
||||
const { fs, host } = tscBuild({
|
||||
fs: projFs.shadow(),
|
||||
tick,
|
||||
rootNames: ["/src"],
|
||||
modifyFs: fs => {
|
||||
changeToIsolatedModules(fs);
|
||||
appendText(fs, "/src/lazyIndex.ts", `
|
||||
import { default as bar } from './bar';
|
||||
bar("hello");`);
|
||||
}
|
||||
});
|
||||
host.assertErrors(/*empty*/);
|
||||
|
||||
tick();
|
||||
const { fs: newFs, host: newHost, writtenFiles } = tscBuild({
|
||||
fs: fs.shadow(),
|
||||
tick,
|
||||
rootNames: ["/src"],
|
||||
modifyFs: changeBarParam
|
||||
});
|
||||
// Has errors
|
||||
newHost.assertErrors({
|
||||
message: [Diagnostics.Expected_0_arguments_but_got_1, 0, 1],
|
||||
location: expectedLocationIndexOf(newFs, "/src/lazyIndex.ts", `"hello"`)
|
||||
});
|
||||
// No written files
|
||||
assert.equal(writtenFiles.size, 0);
|
||||
});
|
||||
});
|
||||
|
||||
function changeToIsolatedModules(fs: vfs.FileSystem) {
|
||||
replaceText(fs, "/src/tsconfig.json", `"incremental": true`, `"incremental": true, "isolatedModules": true`);
|
||||
}
|
||||
|
||||
function changeBarParam(fs: vfs.FileSystem) {
|
||||
replaceText(fs, "/src/bar.ts", "param: string", "");
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,6 @@ namespace ts {
|
||||
tick,
|
||||
proj: "lateBoundSymbol",
|
||||
rootNames: ["/src/tsconfig.json"],
|
||||
lastProjectOutput: "/src/src/main.js",
|
||||
outputFiles: [
|
||||
"/src/src/hkt.js",
|
||||
"/src/src/main.js",
|
||||
"/src/tsconfig.tsbuildinfo",
|
||||
],
|
||||
initialBuild: {
|
||||
modifyFs: noop,
|
||||
expectedDiagnostics: [
|
||||
|
||||
@@ -96,7 +96,6 @@ namespace ts {
|
||||
tick,
|
||||
proj: "moduleSpecifiers",
|
||||
rootNames: ["/"],
|
||||
lastProjectOutput: `/src/lib/index.d.ts`,
|
||||
initialBuild: {
|
||||
modifyFs: noop,
|
||||
},
|
||||
|
||||
@@ -55,19 +55,6 @@ namespace ts {
|
||||
]
|
||||
]
|
||||
];
|
||||
const expectedMapFileNames = [
|
||||
outputFiles[project.first][ext.jsmap],
|
||||
outputFiles[project.first][ext.dtsmap],
|
||||
outputFiles[project.second][ext.jsmap],
|
||||
outputFiles[project.second][ext.dtsmap],
|
||||
outputFiles[project.third][ext.jsmap],
|
||||
outputFiles[project.third][ext.dtsmap]
|
||||
];
|
||||
const expectedTsbuildInfoFileNames: readonly BuildInfoSectionBaselineFiles[] = [
|
||||
[outputFiles[project.first][ext.buildinfo], outputFiles[project.first][ext.js], outputFiles[project.first][ext.dts]],
|
||||
[outputFiles[project.second][ext.buildinfo], outputFiles[project.second][ext.js], outputFiles[project.second][ext.dts]],
|
||||
[outputFiles[project.third][ext.buildinfo], outputFiles[project.third][ext.js], outputFiles[project.third][ext.dts]]
|
||||
];
|
||||
const relSources = sources.map(([config, sources]) => [relName(config), sources.map(relName)]) as any as [Sources, Sources, Sources];
|
||||
const { time, tick } = getTime();
|
||||
let expectedOutputFiles = [
|
||||
@@ -252,7 +239,6 @@ namespace ts {
|
||||
modifyFs: (fs: vfs.FileSystem) => void;
|
||||
modifyAgainFs?: (fs: vfs.FileSystem) => void;
|
||||
additionalSourceFiles?: readonly string[];
|
||||
expectedBuildInfoFilesForSectionBaselines?: readonly BuildInfoSectionBaselineFiles[];
|
||||
dependOrdered?: true;
|
||||
ignoreDtsChanged?: true;
|
||||
ignoreDtsUnchanged?: true;
|
||||
@@ -264,7 +250,6 @@ namespace ts {
|
||||
modifyFs,
|
||||
modifyAgainFs,
|
||||
additionalSourceFiles,
|
||||
expectedBuildInfoFilesForSectionBaselines,
|
||||
dependOrdered,
|
||||
ignoreDtsChanged,
|
||||
ignoreDtsUnchanged,
|
||||
@@ -286,9 +271,7 @@ namespace ts {
|
||||
tick,
|
||||
proj: "outfile-concat",
|
||||
rootNames: ["/src/third"],
|
||||
expectedMapFileNames,
|
||||
expectedBuildInfoFilesForSectionBaselines: expectedBuildInfoFilesForSectionBaselines || expectedTsbuildInfoFileNames,
|
||||
lastProjectOutput: outputFiles[project.third][ext.js],
|
||||
baselineSourceMap: true,
|
||||
initialBuild: {
|
||||
modifyFs,
|
||||
expectedDiagnostics: initialExpectedDiagnostics,
|
||||
@@ -311,7 +294,6 @@ namespace ts {
|
||||
expectedDiagnostics: dtsUnchanged && dtsUnchanged.expectedDiagnostics,
|
||||
expectedReadFiles: dtsUnchanged && dtsUnchanged.expectedReadFiles
|
||||
} : undefined,
|
||||
outputFiles: expectedOutputFiles,
|
||||
baselineOnly
|
||||
});
|
||||
}
|
||||
@@ -344,11 +326,6 @@ namespace ts {
|
||||
scenario: "when final project specifies tsBuildInfoFile",
|
||||
modifyFs: fs => replaceText(fs, sources[project.third][source.config], `"composite": true,`, `"composite": true,
|
||||
"tsBuildInfoFile": "./thirdjs/output/third.tsbuildinfo",`),
|
||||
expectedBuildInfoFilesForSectionBaselines: [
|
||||
expectedTsbuildInfoFileNames[0],
|
||||
expectedTsbuildInfoFileNames[1],
|
||||
["/src/third/thirdjs/output/third.tsbuildinfo", expectedTsbuildInfoFileNames[2][1], expectedTsbuildInfoFileNames[2][2]]
|
||||
],
|
||||
ignoreDtsChanged: true,
|
||||
ignoreDtsUnchanged: true,
|
||||
baselineOnly: true
|
||||
|
||||
@@ -612,12 +612,7 @@ export class cNew {}`);
|
||||
tick,
|
||||
proj: "sample1",
|
||||
rootNames: ["/src/tests"],
|
||||
expectedMapFileNames: [
|
||||
"/src/core/anotherModule.d.ts.map",
|
||||
"/src/core/index.d.ts.map",
|
||||
"/src/logic/index.js.map"
|
||||
],
|
||||
lastProjectOutput: "/src/tests/index.js",
|
||||
baselineSourceMap: true,
|
||||
initialBuild,
|
||||
incrementalDtsChangedBuild: {
|
||||
modifyFs: fs => appendText(fs, "/src/core/index.ts", `
|
||||
@@ -697,22 +692,6 @@ class someClass { }`),
|
||||
],
|
||||
)
|
||||
},
|
||||
outputFiles: [
|
||||
"/src/core/anotherModule.js",
|
||||
"/src/core/anotherModule.d.ts",
|
||||
"/src/core/anotherModule.d.ts.map",
|
||||
"/src/core/index.js",
|
||||
"/src/core/index.d.ts",
|
||||
"/src/core/index.d.ts.map",
|
||||
"/src/core/tsconfig.tsbuildinfo",
|
||||
"/src/logic/index.js",
|
||||
"/src/logic/index.js.map",
|
||||
"/src/logic/index.d.ts",
|
||||
"/src/logic/tsconfig.tsbuildinfo",
|
||||
"/src/tests/index.js",
|
||||
"/src/tests/index.d.ts",
|
||||
"/src/tests/tsconfig.tsbuildinfo",
|
||||
]
|
||||
});
|
||||
|
||||
verifyTsbuildOutput({
|
||||
@@ -722,12 +701,7 @@ class someClass { }`),
|
||||
tick,
|
||||
proj: "sample1",
|
||||
rootNames: ["/src/tests"],
|
||||
expectedMapFileNames: [
|
||||
"/src/core/anotherModule.d.ts.map",
|
||||
"/src/core/index.d.ts.map",
|
||||
"/src/logic/index.js.map"
|
||||
],
|
||||
lastProjectOutput: "/src/tests/index.js",
|
||||
baselineSourceMap: true,
|
||||
initialBuild,
|
||||
incrementalDtsChangedBuild: {
|
||||
modifyFs: fs => replaceText(fs, "/src/logic/tsconfig.json", `"declaration": true,`, `"declaration": true,
|
||||
@@ -765,22 +739,6 @@ class someClass { }`),
|
||||
]
|
||||
)
|
||||
},
|
||||
outputFiles: [
|
||||
"/src/core/anotherModule.js",
|
||||
"/src/core/anotherModule.d.ts",
|
||||
"/src/core/anotherModule.d.ts.map",
|
||||
"/src/core/index.js",
|
||||
"/src/core/index.d.ts",
|
||||
"/src/core/index.d.ts.map",
|
||||
"/src/core/tsconfig.tsbuildinfo",
|
||||
"/src/logic/index.js",
|
||||
"/src/logic/index.js.map",
|
||||
"/src/logic/decls/index.d.ts",
|
||||
"/src/logic/tsconfig.tsbuildinfo",
|
||||
"/src/tests/index.js",
|
||||
"/src/tests/index.d.ts",
|
||||
"/src/tests/tsconfig.tsbuildinfo",
|
||||
],
|
||||
});
|
||||
|
||||
verifyTsbuildOutput({
|
||||
@@ -790,12 +748,7 @@ class someClass { }`),
|
||||
tick,
|
||||
proj: "sample1",
|
||||
rootNames: ["/src/tests"],
|
||||
expectedMapFileNames: [
|
||||
"/src/core/anotherModule.d.ts.map",
|
||||
"/src/core/index.d.ts.map",
|
||||
"/src/logic/index.js.map"
|
||||
],
|
||||
lastProjectOutput: "/src/tests/index.js",
|
||||
baselineSourceMap: true,
|
||||
initialBuild: {
|
||||
modifyFs: fs => replaceText(fs, "/src/logic/tsconfig.json", `"composite": true,`, `"composite": true,
|
||||
"tsBuildInfoFile": "ownFile.tsbuildinfo",`),
|
||||
@@ -826,22 +779,6 @@ class someClass { }`),
|
||||
]
|
||||
)
|
||||
},
|
||||
outputFiles: [
|
||||
"/src/core/anotherModule.js",
|
||||
"/src/core/anotherModule.d.ts",
|
||||
"/src/core/anotherModule.d.ts.map",
|
||||
"/src/core/index.js",
|
||||
"/src/core/index.d.ts",
|
||||
"/src/core/index.d.ts.map",
|
||||
"/src/core/tsconfig.tsbuildinfo",
|
||||
"/src/logic/index.js",
|
||||
"/src/logic/index.js.map",
|
||||
"/src/logic/index.d.ts",
|
||||
"/src/logic/ownFile.tsbuildinfo",
|
||||
"/src/tests/index.js",
|
||||
"/src/tests/index.d.ts",
|
||||
"/src/tests/tsconfig.tsbuildinfo",
|
||||
]
|
||||
});
|
||||
|
||||
verifyTsbuildOutput({
|
||||
@@ -851,7 +788,6 @@ class someClass { }`),
|
||||
tick,
|
||||
proj: "sample1",
|
||||
rootNames: ["/src/core"],
|
||||
lastProjectOutput: "/src/core/index.js",
|
||||
initialBuild: {
|
||||
modifyFs: fs => fs.writeFileSync("/src/core/tsconfig.json", `{
|
||||
"compilerOptions": {
|
||||
@@ -873,13 +809,6 @@ class someClass { }`),
|
||||
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"]
|
||||
]
|
||||
},
|
||||
outputFiles: [
|
||||
"/src/core/anotherModule.js",
|
||||
"/src/core/anotherModule.d.ts",
|
||||
"/src/core/index.js",
|
||||
"/src/core/index.d.ts",
|
||||
"/src/core/tsconfig.tsbuildinfo",
|
||||
],
|
||||
baselineOnly: true,
|
||||
verifyDiagnostics: true
|
||||
});
|
||||
@@ -891,7 +820,6 @@ class someClass { }`),
|
||||
tick,
|
||||
proj: "sample1",
|
||||
rootNames: ["/src/core"],
|
||||
lastProjectOutput: "/src/core/index.js",
|
||||
initialBuild: {
|
||||
modifyFs: fs => {
|
||||
fs.writeFileSync("/lib/lib.esnext.full.d.ts", `/// <reference no-default-lib="true"/>
|
||||
@@ -922,13 +850,6 @@ class someClass { }`),
|
||||
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"]
|
||||
]
|
||||
},
|
||||
outputFiles: [
|
||||
"/src/core/anotherModule.js",
|
||||
"/src/core/anotherModule.d.ts",
|
||||
"/src/core/index.js",
|
||||
"/src/core/index.d.ts",
|
||||
"/src/core/tsconfig.tsbuildinfo",
|
||||
],
|
||||
baselineOnly: true,
|
||||
verifyDiagnostics: true
|
||||
});
|
||||
@@ -940,7 +861,6 @@ class someClass { }`),
|
||||
tick,
|
||||
proj: "sample1",
|
||||
rootNames: ["/src/core"],
|
||||
lastProjectOutput: "/src/core/index.js",
|
||||
initialBuild: {
|
||||
modifyFs: fs => fs.writeFileSync("/src/core/tsconfig.json", `{
|
||||
"compilerOptions": {
|
||||
@@ -962,11 +882,6 @@ class someClass { }`),
|
||||
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"]
|
||||
]
|
||||
},
|
||||
outputFiles: [
|
||||
"/src/core/anotherModule.js",
|
||||
"/src/core/index.js",
|
||||
"/src/core/tsconfig.tsbuildinfo",
|
||||
],
|
||||
baselineOnly: true,
|
||||
verifyDiagnostics: true
|
||||
});
|
||||
@@ -978,7 +893,6 @@ class someClass { }`),
|
||||
tick,
|
||||
proj: "sample1",
|
||||
rootNames: ["/src/tests"],
|
||||
lastProjectOutput: "/src/tests/index.js",
|
||||
initialBuild: {
|
||||
modifyFs: fs => fs.writeFileSync("/src/tests/tsconfig.json", `{
|
||||
"references": [
|
||||
@@ -1014,7 +928,6 @@ class someClass { }`),
|
||||
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
|
||||
]
|
||||
},
|
||||
outputFiles: [],
|
||||
baselineOnly: true,
|
||||
verifyDiagnostics: true
|
||||
});
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace ts.tscWatch {
|
||||
file,
|
||||
fileStamp: host.getModifiedTime(file.path.replace(".ts", ".js")),
|
||||
errors: builderProgram.getSemanticDiagnostics(watch().getSourceFileByPath(file.path as Path)),
|
||||
errorsFromOldState: !!state.semanticDiagnosticsFromOldState && state.semanticDiagnosticsFromOldState.has(file.path)
|
||||
errorsFromOldState: !!state.semanticDiagnosticsFromOldState && state.semanticDiagnosticsFromOldState.has(file.path),
|
||||
dtsStamp: host.getModifiedTime(file.path.replace(".ts", ".d.ts"))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,21 +25,36 @@ namespace ts.tscWatch {
|
||||
return find(stampsAndErrors, info => info.file === file)!;
|
||||
}
|
||||
|
||||
function verifyOutputFileStampsAndErrors(
|
||||
file: File,
|
||||
emitExpected: boolean,
|
||||
errorRefershExpected: boolean,
|
||||
beforeChangeFileStampsAndErrors: readonly ReturnType<typeof getOutputFileStampAndError>[],
|
||||
afterChangeFileStampsAndErrors: readonly ReturnType<typeof getOutputFileStampAndError>[]
|
||||
) {
|
||||
interface VerifyOutputFileStampAndErrors {
|
||||
file: File;
|
||||
jsEmitExpected: boolean;
|
||||
dtsEmitExpected: boolean;
|
||||
errorRefershExpected: boolean;
|
||||
beforeChangeFileStampsAndErrors: readonly ReturnType<typeof getOutputFileStampAndError>[];
|
||||
afterChangeFileStampsAndErrors: readonly ReturnType<typeof getOutputFileStampAndError>[];
|
||||
}
|
||||
function verifyOutputFileStampsAndErrors({
|
||||
file,
|
||||
jsEmitExpected,
|
||||
dtsEmitExpected,
|
||||
errorRefershExpected,
|
||||
beforeChangeFileStampsAndErrors,
|
||||
afterChangeFileStampsAndErrors
|
||||
}: VerifyOutputFileStampAndErrors) {
|
||||
const beforeChange = findStampAndErrors(beforeChangeFileStampsAndErrors, file);
|
||||
const afterChange = findStampAndErrors(afterChangeFileStampsAndErrors, file);
|
||||
if (emitExpected) {
|
||||
if (jsEmitExpected) {
|
||||
assert.notStrictEqual(afterChange.fileStamp, beforeChange.fileStamp, `Expected emit for file ${file.path}`);
|
||||
}
|
||||
else {
|
||||
assert.strictEqual(afterChange.fileStamp, beforeChange.fileStamp, `Did not expect new emit for file ${file.path}`);
|
||||
}
|
||||
if (dtsEmitExpected) {
|
||||
assert.notStrictEqual(afterChange.dtsStamp, beforeChange.dtsStamp, `Expected emit for file ${file.path}`);
|
||||
}
|
||||
else {
|
||||
assert.strictEqual(afterChange.dtsStamp, beforeChange.dtsStamp, `Did not expect new emit for file ${file.path}`);
|
||||
}
|
||||
if (errorRefershExpected) {
|
||||
if (afterChange.errors !== emptyArray || beforeChange.errors !== emptyArray) {
|
||||
assert.notStrictEqual(afterChange.errors, beforeChange.errors, `Expected new errors for file ${file.path}`);
|
||||
@@ -51,19 +67,22 @@ namespace ts.tscWatch {
|
||||
}
|
||||
}
|
||||
|
||||
interface VerifyEmitAndErrorUpdates {
|
||||
change: (host: WatchedSystem) => void;
|
||||
getInitialErrors: (watch: Watch) => readonly Diagnostic[] | readonly string[];
|
||||
getIncrementalErrors: (watch: Watch) => readonly Diagnostic[] | readonly string[];
|
||||
filesWithNewEmit: readonly File[];
|
||||
filesWithOnlyErrorRefresh: readonly File[];
|
||||
filesNotTouched: readonly File[];
|
||||
configFile?: File;
|
||||
interface VerifyEmitAndErrorUpdatesWorker extends VerifyEmitAndErrorUpdates {
|
||||
configFile: File;
|
||||
}
|
||||
|
||||
function verifyEmitAndErrorUpdates({ filesWithNewEmit, filesWithOnlyErrorRefresh, filesNotTouched, configFile = config, change, getInitialErrors, getIncrementalErrors }: VerifyEmitAndErrorUpdates) {
|
||||
function verifyEmitAndErrorUpdatesWorker({
|
||||
fileWithChange,
|
||||
filesWithNewEmit,
|
||||
filesWithOnlyErrorRefresh,
|
||||
filesNotTouched,
|
||||
configFile,
|
||||
change,
|
||||
getInitialErrors,
|
||||
getIncrementalErrors
|
||||
}: VerifyEmitAndErrorUpdatesWorker) {
|
||||
const nonLibFiles = [...filesWithNewEmit, ...filesWithOnlyErrorRefresh, ...filesNotTouched];
|
||||
const files = [...nonLibFiles, configFile, libFile];
|
||||
const compilerOptions = (JSON.parse(configFile.content).compilerOptions || {}) as CompilerOptions;
|
||||
const host = createWatchedSystem(files, { currentDirectory });
|
||||
const watch = createWatchOfConfigFile("tsconfig.json", host);
|
||||
checkProgramActualFiles(watch(), [...nonLibFiles.map(f => f.path), libFile.path]);
|
||||
@@ -73,9 +92,77 @@ namespace ts.tscWatch {
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
checkOutputErrorsIncremental(host, getIncrementalErrors(watch));
|
||||
const afterChange = getOutputFileStampsAndErrors(host, watch, nonLibFiles);
|
||||
filesWithNewEmit.forEach(file => verifyOutputFileStampsAndErrors(file, /*emitExpected*/ true, /*errorRefershExpected*/ true, beforeChange, afterChange));
|
||||
filesWithOnlyErrorRefresh.forEach(file => verifyOutputFileStampsAndErrors(file, /*emitExpected*/ false, /*errorRefershExpected*/ true, beforeChange, afterChange));
|
||||
filesNotTouched.forEach(file => verifyOutputFileStampsAndErrors(file, /*emitExpected*/ false, /*errorRefershExpected*/ false, beforeChange, afterChange));
|
||||
filesWithNewEmit.forEach(file => verifyOutputFileStampsAndErrors({
|
||||
file,
|
||||
jsEmitExpected: !compilerOptions.isolatedModules || fileWithChange === file,
|
||||
dtsEmitExpected: getEmitDeclarations(compilerOptions),
|
||||
errorRefershExpected: true,
|
||||
beforeChangeFileStampsAndErrors: beforeChange,
|
||||
afterChangeFileStampsAndErrors: afterChange
|
||||
}));
|
||||
filesWithOnlyErrorRefresh.forEach(file => verifyOutputFileStampsAndErrors({
|
||||
file,
|
||||
jsEmitExpected: false,
|
||||
dtsEmitExpected: getEmitDeclarations(compilerOptions) && !file.path.endsWith(".d.ts"),
|
||||
errorRefershExpected: true,
|
||||
beforeChangeFileStampsAndErrors: beforeChange,
|
||||
afterChangeFileStampsAndErrors: afterChange
|
||||
}));
|
||||
filesNotTouched.forEach(file => verifyOutputFileStampsAndErrors({
|
||||
file,
|
||||
jsEmitExpected: false,
|
||||
dtsEmitExpected: false,
|
||||
errorRefershExpected: false,
|
||||
beforeChangeFileStampsAndErrors: beforeChange,
|
||||
afterChangeFileStampsAndErrors: afterChange
|
||||
}));
|
||||
}
|
||||
|
||||
function changeCompilerOptions(input: VerifyEmitAndErrorUpdates, additionalOptions: CompilerOptions): File {
|
||||
const configFile = input.configFile || config;
|
||||
const content = JSON.parse(configFile.content);
|
||||
content.compilerOptions = { ...content.compilerOptions, ...additionalOptions };
|
||||
return { path: configFile.path, content: JSON.stringify(content) };
|
||||
}
|
||||
|
||||
interface VerifyEmitAndErrorUpdates {
|
||||
change: (host: WatchedSystem) => void;
|
||||
getInitialErrors: (watch: Watch) => readonly Diagnostic[] | readonly string[];
|
||||
getIncrementalErrors: (watch: Watch) => readonly Diagnostic[] | readonly string[];
|
||||
fileWithChange: File;
|
||||
filesWithNewEmit: readonly File[];
|
||||
filesWithOnlyErrorRefresh: readonly File[];
|
||||
filesNotTouched: readonly File[];
|
||||
configFile?: File;
|
||||
}
|
||||
function verifyEmitAndErrorUpdates(input: VerifyEmitAndErrorUpdates) {
|
||||
it("with default config", () => {
|
||||
verifyEmitAndErrorUpdatesWorker({
|
||||
...input,
|
||||
configFile: input.configFile || config
|
||||
});
|
||||
});
|
||||
|
||||
it("with default config and --declaration", () => {
|
||||
verifyEmitAndErrorUpdatesWorker({
|
||||
...input,
|
||||
configFile: changeCompilerOptions(input, { declaration: true })
|
||||
});
|
||||
});
|
||||
|
||||
it("config with --isolatedModules", () => {
|
||||
verifyEmitAndErrorUpdatesWorker({
|
||||
...input,
|
||||
configFile: changeCompilerOptions(input, { isolatedModules: true })
|
||||
});
|
||||
});
|
||||
|
||||
it("config with --isolatedModules and --declaration", () => {
|
||||
verifyEmitAndErrorUpdatesWorker({
|
||||
...input,
|
||||
configFile: changeCompilerOptions(input, { isolatedModules: true, declaration: true })
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe("deep import changes", () => {
|
||||
@@ -93,6 +180,7 @@ console.log(b.c.d);`
|
||||
addImportedModule(bFile);
|
||||
addImportedModule(cFile);
|
||||
verifyEmitAndErrorUpdates({
|
||||
fileWithChange: cFile,
|
||||
filesWithNewEmit,
|
||||
filesWithOnlyErrorRefresh,
|
||||
filesNotTouched: emptyArray,
|
||||
@@ -113,7 +201,7 @@ console.log(b.c.d);`
|
||||
}
|
||||
}
|
||||
|
||||
it("updates errors when deep import file changes", () => {
|
||||
describe("updates errors when deep import file changes", () => {
|
||||
const bFile: File = {
|
||||
path: `${currentDirectory}/b.ts`,
|
||||
content: `import {C} from './c';
|
||||
@@ -132,7 +220,7 @@ export class B
|
||||
verifyDeepImportChange(bFile, cFile);
|
||||
});
|
||||
|
||||
it("updates errors when deep import through declaration file changes", () => {
|
||||
describe("updates errors when deep import through declaration file changes", () => {
|
||||
const bFile: File = {
|
||||
path: `${currentDirectory}/b.d.ts`,
|
||||
content: `import {C} from './c';
|
||||
@@ -152,7 +240,7 @@ export class B
|
||||
});
|
||||
});
|
||||
|
||||
it("updates errors in file not exporting a deep multilevel import that changes", () => {
|
||||
describe("updates errors in file not exporting a deep multilevel import that changes", () => {
|
||||
const aFile: File = {
|
||||
path: `${currentDirectory}/a.ts`,
|
||||
content: `export interface Point {
|
||||
@@ -193,6 +281,7 @@ getPoint().c.x;`
|
||||
content: `import "./d";`
|
||||
};
|
||||
verifyEmitAndErrorUpdates({
|
||||
fileWithChange: aFile,
|
||||
filesWithNewEmit: [aFile, bFile],
|
||||
filesWithOnlyErrorRefresh: [cFile, dFile],
|
||||
filesNotTouched: [eFile],
|
||||
@@ -265,6 +354,7 @@ export class Data {
|
||||
filesWithOnlyErrorRefresh.push(lib2Data2);
|
||||
}
|
||||
verifyEmitAndErrorUpdates({
|
||||
fileWithChange: lib1ToolsInterface,
|
||||
filesWithNewEmit,
|
||||
filesWithOnlyErrorRefresh,
|
||||
filesNotTouched: emptyArray,
|
||||
@@ -276,11 +366,11 @@ export class Data {
|
||||
]
|
||||
});
|
||||
}
|
||||
it("when there are no circular import and exports", () => {
|
||||
describe("when there are no circular import and exports", () => {
|
||||
verifyTransitiveExports(lib2Data);
|
||||
});
|
||||
|
||||
it("when there are circular import and exports", () => {
|
||||
describe("when there are circular import and exports", () => {
|
||||
const lib2Data: File = {
|
||||
path: `${currentDirectory}/lib2/data.ts`,
|
||||
content: `import { ITest } from "lib1/public"; import { Data2 } from "./data2";
|
||||
|
||||
+12
-1
@@ -1893,6 +1893,15 @@ declare namespace ts {
|
||||
* Gets a type checker that can be used to semantically analyze source files in the program.
|
||||
*/
|
||||
getTypeChecker(): TypeChecker;
|
||||
getNodeCount(): number;
|
||||
getIdentifierCount(): number;
|
||||
getSymbolCount(): number;
|
||||
getTypeCount(): number;
|
||||
getRelationCacheSizes(): {
|
||||
assignable: number;
|
||||
identity: number;
|
||||
subtype: number;
|
||||
};
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
isSourceFileDefaultLibrary(file: SourceFile): boolean;
|
||||
getProjectReferences(): readonly ProjectReference[] | undefined;
|
||||
@@ -3293,7 +3302,7 @@ declare namespace ts {
|
||||
parent: ConstructorDeclaration;
|
||||
name: Identifier;
|
||||
};
|
||||
function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration;
|
||||
function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration;
|
||||
function isEmptyBindingPattern(node: BindingName): node is BindingPattern;
|
||||
function isEmptyBindingElement(node: BindingElement): boolean;
|
||||
function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration;
|
||||
@@ -4310,6 +4319,8 @@ declare namespace ts {
|
||||
function visitEachChild<T extends Node>(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined;
|
||||
}
|
||||
declare namespace ts {
|
||||
function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined;
|
||||
function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[];
|
||||
function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer;
|
||||
}
|
||||
declare namespace ts {
|
||||
|
||||
+12
-1
@@ -1893,6 +1893,15 @@ declare namespace ts {
|
||||
* Gets a type checker that can be used to semantically analyze source files in the program.
|
||||
*/
|
||||
getTypeChecker(): TypeChecker;
|
||||
getNodeCount(): number;
|
||||
getIdentifierCount(): number;
|
||||
getSymbolCount(): number;
|
||||
getTypeCount(): number;
|
||||
getRelationCacheSizes(): {
|
||||
assignable: number;
|
||||
identity: number;
|
||||
subtype: number;
|
||||
};
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
isSourceFileDefaultLibrary(file: SourceFile): boolean;
|
||||
getProjectReferences(): readonly ProjectReference[] | undefined;
|
||||
@@ -3293,7 +3302,7 @@ declare namespace ts {
|
||||
parent: ConstructorDeclaration;
|
||||
name: Identifier;
|
||||
};
|
||||
function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration;
|
||||
function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration;
|
||||
function isEmptyBindingPattern(node: BindingName): node is BindingPattern;
|
||||
function isEmptyBindingElement(node: BindingElement): boolean;
|
||||
function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration;
|
||||
@@ -4310,6 +4319,8 @@ declare namespace ts {
|
||||
function visitEachChild<T extends Node>(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined;
|
||||
}
|
||||
declare namespace ts {
|
||||
function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined;
|
||||
function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[];
|
||||
function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer;
|
||||
}
|
||||
declare namespace ts {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(10,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(11,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(12,5): error TS1005: ',' expected.
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(12,5): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(12,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ tests/cases/conformance/constEnums/constEnum2.ts(12,9): error TS2474: const enum
|
||||
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
g = CONST,
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~~~~~
|
||||
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [customAsyncIterator.ts]
|
||||
// GH: https://github.com/microsoft/TypeScript/issues/33239
|
||||
class ConstantIterator<T> implements AsyncIterator<T, undefined, T | undefined> {
|
||||
constructor(private constant: T) {
|
||||
}
|
||||
async next(value?: T): Promise<IteratorResult<T>> {
|
||||
if (value != null) {
|
||||
throw new Error("ConstantIterator.prototype.next may not take any values");
|
||||
}
|
||||
return { value: this.constant, done: false };
|
||||
}
|
||||
}
|
||||
|
||||
//// [customAsyncIterator.js]
|
||||
// GH: https://github.com/microsoft/TypeScript/issues/33239
|
||||
class ConstantIterator {
|
||||
constructor(constant) {
|
||||
this.constant = constant;
|
||||
}
|
||||
async next(value) {
|
||||
if (value != null) {
|
||||
throw new Error("ConstantIterator.prototype.next may not take any values");
|
||||
}
|
||||
return { value: this.constant, done: false };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/compiler/customAsyncIterator.ts ===
|
||||
// GH: https://github.com/microsoft/TypeScript/issues/33239
|
||||
class ConstantIterator<T> implements AsyncIterator<T, undefined, T | undefined> {
|
||||
>ConstantIterator : Symbol(ConstantIterator, Decl(customAsyncIterator.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(customAsyncIterator.ts, 1, 23))
|
||||
>AsyncIterator : Symbol(AsyncIterator, Decl(lib.es2018.asynciterable.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(customAsyncIterator.ts, 1, 23))
|
||||
>T : Symbol(T, Decl(customAsyncIterator.ts, 1, 23))
|
||||
|
||||
constructor(private constant: T) {
|
||||
>constant : Symbol(ConstantIterator.constant, Decl(customAsyncIterator.ts, 2, 16))
|
||||
>T : Symbol(T, Decl(customAsyncIterator.ts, 1, 23))
|
||||
}
|
||||
async next(value?: T): Promise<IteratorResult<T>> {
|
||||
>next : Symbol(ConstantIterator.next, Decl(customAsyncIterator.ts, 3, 5))
|
||||
>value : Symbol(value, Decl(customAsyncIterator.ts, 4, 15))
|
||||
>T : Symbol(T, Decl(customAsyncIterator.ts, 1, 23))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
|
||||
>IteratorResult : Symbol(IteratorResult, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(customAsyncIterator.ts, 1, 23))
|
||||
|
||||
if (value != null) {
|
||||
>value : Symbol(value, Decl(customAsyncIterator.ts, 4, 15))
|
||||
|
||||
throw new Error("ConstantIterator.prototype.next may not take any values");
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
return { value: this.constant, done: false };
|
||||
>value : Symbol(value, Decl(customAsyncIterator.ts, 8, 16))
|
||||
>this.constant : Symbol(ConstantIterator.constant, Decl(customAsyncIterator.ts, 2, 16))
|
||||
>this : Symbol(ConstantIterator, Decl(customAsyncIterator.ts, 0, 0))
|
||||
>constant : Symbol(ConstantIterator.constant, Decl(customAsyncIterator.ts, 2, 16))
|
||||
>done : Symbol(done, Decl(customAsyncIterator.ts, 8, 38))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
=== tests/cases/compiler/customAsyncIterator.ts ===
|
||||
// GH: https://github.com/microsoft/TypeScript/issues/33239
|
||||
class ConstantIterator<T> implements AsyncIterator<T, undefined, T | undefined> {
|
||||
>ConstantIterator : ConstantIterator<T>
|
||||
|
||||
constructor(private constant: T) {
|
||||
>constant : T
|
||||
}
|
||||
async next(value?: T): Promise<IteratorResult<T>> {
|
||||
>next : (value?: T) => Promise<IteratorResult<T, any>>
|
||||
>value : T
|
||||
|
||||
if (value != null) {
|
||||
>value != null : boolean
|
||||
>value : T
|
||||
>null : null
|
||||
|
||||
throw new Error("ConstantIterator.prototype.next may not take any values");
|
||||
>new Error("ConstantIterator.prototype.next may not take any values") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"ConstantIterator.prototype.next may not take any values" : "ConstantIterator.prototype.next may not take any values"
|
||||
}
|
||||
return { value: this.constant, done: false };
|
||||
>{ value: this.constant, done: false } : { value: T; done: false; }
|
||||
>value : T
|
||||
>this.constant : T
|
||||
>this : this
|
||||
>constant : T
|
||||
>done : false
|
||||
>false : false
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ XX of XX: [@azure/event-hubs] completed successfully in ? seconds
|
||||
XX of XX: [@azure/event-processor-host] completed successfully in ? seconds
|
||||
XX of XX: [@azure/keyvault-keys] completed successfully in ? seconds
|
||||
XX of XX: [@azure/keyvault-secrets] completed successfully in ? seconds
|
||||
XX of XX: [@azure/app-configuration] completed successfully in ? seconds
|
||||
Warning: You have changed the public API signature for this project. Updating review/app-configuration.api.md
|
||||
XX of XX: [@azure/core-asynciterator-polyfill] completed successfully in ? seconds
|
||||
Warning: You have changed the public API signature for this project. Updating review/cosmos.api.md
|
||||
dist-esm/index.js → dist/index.js...
|
||||
@@ -39,7 +39,7 @@ crypto-hash (imported by dist-esm/queryExecutionContext/EndpointComponent/Ordere
|
||||
fast-json-stable-stringify (imported by dist-esm/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js, dist-esm/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js)
|
||||
(!) Missing global variable names
|
||||
Use output.globals to specify browser global variable names corresponding to external modules
|
||||
universal-user-agent (guessing 'userAgent')
|
||||
universal-user-agent (guessing 'universalUserAgent')
|
||||
tslib (guessing 'tslib')
|
||||
@azure/cosmos-sign (guessing 'cosmosSign')
|
||||
debug (guessing 'debugLib')
|
||||
@@ -64,7 +64,7 @@ XX of XX: [@azure/storage-file] completed successfully in ? seconds
|
||||
XX of XX: [@azure/storage-queue] completed successfully in ? seconds
|
||||
XX of XX: [@azure/template] completed successfully in ? seconds
|
||||
XX of XX: [testhub] completed successfully in ? seconds
|
||||
SUCCESS (22)
|
||||
SUCCESS (21)
|
||||
================================
|
||||
@azure/abort-controller (? seconds)
|
||||
@azure/core-auth (? seconds)
|
||||
@@ -79,7 +79,6 @@ SUCCESS (22)
|
||||
@azure/event-processor-host (? seconds)
|
||||
@azure/keyvault-keys (? seconds)
|
||||
@azure/keyvault-secrets (? seconds)
|
||||
@azure/app-configuration (? seconds)
|
||||
@azure/core-asynciterator-polyfill (? seconds)
|
||||
@azure/eventhubs-checkpointstore-blob (? seconds)
|
||||
@azure/keyvault-certificates (? seconds)
|
||||
@@ -89,8 +88,10 @@ SUCCESS (22)
|
||||
@azure/template (? seconds)
|
||||
testhub (? seconds)
|
||||
================================
|
||||
SUCCESS WITH WARNINGS (2)
|
||||
SUCCESS WITH WARNINGS (3)
|
||||
================================
|
||||
@azure/app-configuration (? seconds)
|
||||
Warning: You have changed the public API signature for this project. Updating review/app-configuration.api.md
|
||||
@azure/cosmos (? seconds)
|
||||
Warning: You have changed the public API signature for this project. Updating review/cosmos.api.md
|
||||
dist-esm/index.js → dist/index.js...
|
||||
@@ -111,7 +112,7 @@ crypto-hash (imported by dist-esm/queryExecutionContext/EndpointComponent/Ordere
|
||||
fast-json-stable-stringify (imported by dist-esm/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js, dist-esm/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js)
|
||||
(!) Missing global variable names
|
||||
Use output.globals to specify browser global variable names corresponding to external modules
|
||||
universal-user-agent (guessing 'userAgent')
|
||||
universal-user-agent (guessing 'universalUserAgent')
|
||||
tslib (guessing 'tslib')
|
||||
@azure/cosmos-sign (guessing 'cosmosSign')
|
||||
debug (guessing 'debugLib')
|
||||
@@ -136,6 +137,7 @@ rush rebuild ( ? seconds)
|
||||
|
||||
|
||||
Standard error:
|
||||
XX of XX: [@azure/app-configuration] completed with warnings in ? seconds
|
||||
XX of XX: [@azure/cosmos] completed with warnings in ? seconds
|
||||
XX of XX: [@azure/service-bus] completed with warnings in ? seconds
|
||||
Project(s) succeeded with warnings
|
||||
@@ -34,6 +34,12 @@ Standard output:
|
||||
@uifabric/migration: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/migration/tsconfig.json
|
||||
@uifabric/migration: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --inlineSources --sourceRoot "../src" --outDir lib --module commonjs --project "/office-ui-fabric-react/packages/migration/tsconfig.json"
|
||||
@uifabric/migration: Done in ?s.
|
||||
@uifabric/monaco-editor: yarn run vX.X.X
|
||||
@uifabric/monaco-editor: $ just-scripts build --production --lint
|
||||
@uifabric/monaco-editor: [XX:XX:XX XM] ■ Removing [esm, lib]
|
||||
@uifabric/monaco-editor: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/monaco-editor/tsconfig.json
|
||||
@uifabric/monaco-editor: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --inlineSources --sourceRoot "../src" --outDir lib --module esnext --project "/office-ui-fabric-react/packages/monaco-editor/tsconfig.json"
|
||||
@uifabric/monaco-editor: Done in ?s.
|
||||
@uifabric/set-version: yarn run vX.X.X
|
||||
@uifabric/set-version: $ just-scripts build --production --lint
|
||||
@uifabric/set-version: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts]
|
||||
@@ -84,7 +90,7 @@ Standard output:
|
||||
@uifabric/merge-styles: PASS src/Stylesheet.test.ts
|
||||
@uifabric/merge-styles: PASS src/extractStyleParts.test.ts
|
||||
@uifabric/merge-styles: PASS src/server.test.ts
|
||||
@uifabric/merge-styles: PASS src/fontFace.test.ts
|
||||
@uifabric/merge-styles: PASS src/concatStyleSetsWithProps.test.ts
|
||||
@uifabric/merge-styles: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/merge-styles/lib/index.d.ts'
|
||||
@uifabric/merge-styles: Done in ?s.
|
||||
@uifabric/jest-serializer-merge-styles: yarn run vX.X.X
|
||||
@@ -161,6 +167,26 @@ Standard output:
|
||||
@uifabric/utilities: PASS src/keyboard.test.ts
|
||||
@uifabric/utilities: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/utilities/lib/index.d.ts'
|
||||
@uifabric/utilities: Done in ?s.
|
||||
@uifabric/react-hooks: yarn run vX.X.X
|
||||
@uifabric/react-hooks: $ just-scripts build --production --lint
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts]
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Running tslint
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ /usr/local/bin/node "/office-ui-fabric-react/node_modules/tslint/lib/tslintCli.js" --project "/office-ui-fabric-react/packages/react-hooks/tsconfig.json" -t stylish -r /office-ui-fabric-react/node_modules/tslint-microsoft-contrib
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/react-hooks/tsconfig.json
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --inlineSources --sourceRoot "../src" --outDir lib-commonjs --module commonjs --project "/office-ui-fabric-react/packages/react-hooks/tsconfig.json"
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/react-hooks/tsconfig.json
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --inlineSources --sourceRoot "../src" --outDir lib --module esnext --project "/office-ui-fabric-react/packages/react-hooks/tsconfig.json"
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/react-hooks/tsconfig.json
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --inlineSources --sourceRoot "../src" --outDir lib-amd --module amd --project "/office-ui-fabric-react/packages/react-hooks/tsconfig.json"
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Running Jest
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ /usr/local/bin/node "/office-ui-fabric-react/node_modules/jest/bin/jest.js" --config "/office-ui-fabric-react/packages/react-hooks/jest.config.js" --passWithNoTests --colors --forceExit
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Running Webpack
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Webpack Config Path: /office-ui-fabric-react/packages/react-hooks/webpack.config.js
|
||||
@uifabric/react-hooks: Webpack version: 4.29.5
|
||||
@uifabric/react-hooks: PASS src/useConst.test.tsx
|
||||
@uifabric/react-hooks: PASS src/useId.test.tsx
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/react-hooks/lib/index.d.ts'
|
||||
@uifabric/react-hooks: Done in ?s.
|
||||
@uifabric/styling: yarn run vX.X.X
|
||||
@uifabric/styling: $ just-scripts build --production --lint
|
||||
@uifabric/styling: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts]
|
||||
@@ -223,7 +249,7 @@ Standard output:
|
||||
Standard error:
|
||||
info cli using local version of lerna
|
||||
lerna notice cli vX.X.X
|
||||
lerna info Executing command in 41 packages: "yarn run build --production --lint"
|
||||
lerna info Executing command in 43 packages: "yarn run build --production --lint"
|
||||
@uifabric/codepen-loader: ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
|
||||
@uifabric/codepen-loader: Force exiting Jest
|
||||
@uifabric/codepen-loader:
|
||||
@@ -244,6 +270,11 @@ lerna info Executing command in 41 packages: "yarn run build --production --lint
|
||||
@uifabric/utilities: Force exiting Jest
|
||||
@uifabric/utilities:
|
||||
@uifabric/utilities: Have you considered using `--detectOpenHandles` to detect async operations that kept running after all tests finished?
|
||||
@uifabric/react-hooks: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect
|
||||
@uifabric/react-hooks: ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
|
||||
@uifabric/react-hooks: Force exiting Jest
|
||||
@uifabric/react-hooks:
|
||||
@uifabric/react-hooks: Have you considered using `--detectOpenHandles` to detect async operations that kept running after all tests finished?
|
||||
@uifabric/styling: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect
|
||||
@uifabric/styling: ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
|
||||
@uifabric/styling: Force exiting Jest
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
Exit Code: 0
|
||||
Exit Code: 1
|
||||
Standard output:
|
||||
yarn run vX.X.X
|
||||
$ gulp compile --max_old_space_size=4095
|
||||
[XX:XX:XX] Node flags detected: --max_old_space_size=4095
|
||||
[XX:XX:XX] Using gulpfile /vscode/gulpfile.js
|
||||
Done in ?s.
|
||||
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
|
||||
|
||||
|
||||
|
||||
Standard error:
|
||||
{"type":"warning","data":"package.json: No license field"}
|
||||
{"type":"warning","data":"../package.json: No license field"}
|
||||
{"type":"warning","data":"vscode-web@X.X.X: No license field"}
|
||||
[XX:XX:XX] 'compile' errored after ?s
|
||||
[XX:XX:XX] TypeError: Cannot read property 'text' of undefined
|
||||
at DeclarationResolver._getDeclarationSourceFile (/vscode/build/monaco/api.js:519:75)
|
||||
at DeclarationResolver.getDeclarationSourceFile (/vscode/build/monaco/api.js:493:52)
|
||||
at sourceFileGetter (/vscode/build/monaco/api.js:525:53)
|
||||
at lines.forEach.line (/vscode/build/monaco/api.js:330:32)
|
||||
at Array.forEach (<anonymous>)
|
||||
at generateDeclarationFile (/vscode/build/monaco/api.js:319:11)
|
||||
at _run (/vscode/build/monaco/api.js:438:15)
|
||||
at Object.run3 (/vscode/build/monaco/api.js:526:12)
|
||||
at MonacoGenerator._run (/vscode/build/lib/compilation.js:142:27)
|
||||
at MonacoGenerator.execute (/vscode/build/lib/compilation.js:154:29)
|
||||
error Command failed with exit code 1.
|
||||
@@ -11,9 +11,19 @@ tests/cases/conformance/enums/enumErrors.ts(35,9): error TS2553: Computed values
|
||||
tests/cases/conformance/enums/enumErrors.ts(36,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumErrors.ts(37,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumErrors.ts(38,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumErrors.ts(46,18): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(47,24): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(47,26): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/enums/enumErrors.ts(48,28): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(48,30): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/enums/enumErrors.ts(48,31): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(51,16): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(51,22): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(51,30): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(51,33): error TS2452: An enum member cannot have a numeric name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/enums/enumErrors.ts (13 errors) ====
|
||||
==== tests/cases/conformance/enums/enumErrors.ts (23 errors) ====
|
||||
// Enum named with PredefinedTypes
|
||||
enum any { }
|
||||
~~~
|
||||
@@ -79,4 +89,36 @@ tests/cases/conformance/enums/enumErrors.ts(38,9): error TS2553: Computed values
|
||||
~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
}
|
||||
|
||||
// Enum with incorrect syntax
|
||||
enum E13 {
|
||||
postComma,
|
||||
postValueComma = 1,
|
||||
|
||||
postSemicolon;
|
||||
~
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
postColonValueComma: 2,
|
||||
~
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
postColonValueSemicolon: 3;
|
||||
~
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
~
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
};
|
||||
|
||||
enum E14 { a, b: any "hello" += 1, c, d}
|
||||
~
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~~~~~~~
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~~
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
|
||||
@@ -38,6 +38,18 @@ enum E12 {
|
||||
D = {},
|
||||
E = 1 + 1,
|
||||
}
|
||||
|
||||
// Enum with incorrect syntax
|
||||
enum E13 {
|
||||
postComma,
|
||||
postValueComma = 1,
|
||||
|
||||
postSemicolon;
|
||||
postColonValueComma: 2,
|
||||
postColonValueSemicolon: 3;
|
||||
};
|
||||
|
||||
enum E14 { a, b: any "hello" += 1, c, d}
|
||||
|
||||
|
||||
//// [enumErrors.js]
|
||||
@@ -88,3 +100,25 @@ var E12;
|
||||
E12[E12["D"] = 0] = "D";
|
||||
E12[E12["E"] = 0] = "E";
|
||||
})(E12 || (E12 = {}));
|
||||
// Enum with incorrect syntax
|
||||
var E13;
|
||||
(function (E13) {
|
||||
E13[E13["postComma"] = 0] = "postComma";
|
||||
E13[E13["postValueComma"] = 1] = "postValueComma";
|
||||
E13[E13["postSemicolon"] = 2] = "postSemicolon";
|
||||
E13[E13["postColonValueComma"] = 3] = "postColonValueComma";
|
||||
E13[E13[2] = 4] = 2;
|
||||
E13[E13["postColonValueSemicolon"] = 5] = "postColonValueSemicolon";
|
||||
E13[E13[3] = 6] = 3;
|
||||
})(E13 || (E13 = {}));
|
||||
;
|
||||
var E14;
|
||||
(function (E14) {
|
||||
E14[E14["a"] = 0] = "a";
|
||||
E14[E14["b"] = 1] = "b";
|
||||
E14[E14["any"] = 2] = "any";
|
||||
E14[E14["hello"] = 3] = "hello";
|
||||
E14[E14[1] = 4] = 1;
|
||||
E14[E14["c"] = 5] = "c";
|
||||
E14[E14["d"] = 6] = "d";
|
||||
})(E14 || (E14 = {}));
|
||||
@@ -91,3 +91,36 @@ enum E12 {
|
||||
>E : Symbol(E12.E, Decl(enumErrors.ts, 36, 11))
|
||||
}
|
||||
|
||||
// Enum with incorrect syntax
|
||||
enum E13 {
|
||||
>E13 : Symbol(E13, Decl(enumErrors.ts, 38, 1))
|
||||
|
||||
postComma,
|
||||
>postComma : Symbol(E13.postComma, Decl(enumErrors.ts, 41, 10))
|
||||
|
||||
postValueComma = 1,
|
||||
>postValueComma : Symbol(E13.postValueComma, Decl(enumErrors.ts, 42, 14))
|
||||
|
||||
postSemicolon;
|
||||
>postSemicolon : Symbol(E13.postSemicolon, Decl(enumErrors.ts, 43, 23))
|
||||
|
||||
postColonValueComma: 2,
|
||||
>postColonValueComma : Symbol(E13.postColonValueComma, Decl(enumErrors.ts, 45, 18))
|
||||
>2 : Symbol(E13[2], Decl(enumErrors.ts, 46, 24))
|
||||
|
||||
postColonValueSemicolon: 3;
|
||||
>postColonValueSemicolon : Symbol(E13.postColonValueSemicolon, Decl(enumErrors.ts, 46, 27))
|
||||
>3 : Symbol(E13[3], Decl(enumErrors.ts, 47, 28))
|
||||
|
||||
};
|
||||
|
||||
enum E14 { a, b: any "hello" += 1, c, d}
|
||||
>E14 : Symbol(E14, Decl(enumErrors.ts, 48, 2))
|
||||
>a : Symbol(E14.a, Decl(enumErrors.ts, 50, 10))
|
||||
>b : Symbol(E14.b, Decl(enumErrors.ts, 50, 13))
|
||||
>any : Symbol(E14.any, Decl(enumErrors.ts, 50, 16))
|
||||
>"hello" : Symbol(E14["hello"], Decl(enumErrors.ts, 50, 20))
|
||||
>1 : Symbol(E14[1], Decl(enumErrors.ts, 50, 31))
|
||||
>c : Symbol(E14.c, Decl(enumErrors.ts, 50, 34))
|
||||
>d : Symbol(E14.d, Decl(enumErrors.ts, 50, 37))
|
||||
|
||||
@@ -102,3 +102,37 @@ enum E12 {
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
// Enum with incorrect syntax
|
||||
enum E13 {
|
||||
>E13 : E13
|
||||
|
||||
postComma,
|
||||
>postComma : E13.postComma
|
||||
|
||||
postValueComma = 1,
|
||||
>postValueComma : E13.postValueComma
|
||||
>1 : 1
|
||||
|
||||
postSemicolon;
|
||||
>postSemicolon : E13.postSemicolon
|
||||
|
||||
postColonValueComma: 2,
|
||||
>postColonValueComma : E13.postColonValueComma
|
||||
>2 : E13.2
|
||||
|
||||
postColonValueSemicolon: 3;
|
||||
>postColonValueSemicolon : E13.postColonValueSemicolon
|
||||
>3 : E13.3
|
||||
|
||||
};
|
||||
|
||||
enum E14 { a, b: any "hello" += 1, c, d}
|
||||
>E14 : E14
|
||||
>a : E14.a
|
||||
>b : E14.b
|
||||
>any : E14.any
|
||||
>"hello" : E14.hello
|
||||
>1 : E14.1
|
||||
>c : E14.c
|
||||
>d : E14.d
|
||||
|
||||
@@ -5,7 +5,7 @@ const myObj: { member(x: number, y: string): void } = {
|
||||
}
|
||||
|
||||
// ==SCOPE::Extract to constant in enclosing scope==
|
||||
const newLocal: (x: number, y: string) => void = (x, y) => x + y;
|
||||
const newLocal = (x: number, y: string): string => x + y;
|
||||
const myObj: { member(x: number, y: string): void } = {
|
||||
member: /*RENAME*/newLocal,
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [tests/cases/compiler/interfaceMergedUnconstrainedNoErrorIrrespectiveOfOrder.ts] ////
|
||||
|
||||
//// [working.ts]
|
||||
// minmal samples from #33395
|
||||
export namespace ns {
|
||||
interface Function<T extends (...args: any) => any> {
|
||||
throttle(): Function<T>;
|
||||
}
|
||||
interface Function<T> {
|
||||
unary(): Function<() => ReturnType<T>>;
|
||||
}
|
||||
}
|
||||
//// [regression.ts]
|
||||
export namespace ns {
|
||||
interface Function<T> {
|
||||
unary(): Function<() => ReturnType<T>>;
|
||||
}
|
||||
interface Function<T extends (...args: any) => any> {
|
||||
throttle(): Function<T>;
|
||||
}
|
||||
}
|
||||
|
||||
//// [working.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
//// [regression.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
=== tests/cases/compiler/working.ts ===
|
||||
// minmal samples from #33395
|
||||
export namespace ns {
|
||||
>ns : Symbol(ns, Decl(working.ts, 0, 0))
|
||||
|
||||
interface Function<T extends (...args: any) => any> {
|
||||
>Function : Symbol(Function, Decl(working.ts, 1, 21), Decl(working.ts, 4, 5))
|
||||
>T : Symbol(T, Decl(working.ts, 2, 23), Decl(working.ts, 5, 23))
|
||||
>args : Symbol(args, Decl(working.ts, 2, 34))
|
||||
|
||||
throttle(): Function<T>;
|
||||
>throttle : Symbol(Function.throttle, Decl(working.ts, 2, 57))
|
||||
>Function : Symbol(Function, Decl(working.ts, 1, 21), Decl(working.ts, 4, 5))
|
||||
>T : Symbol(T, Decl(working.ts, 2, 23), Decl(working.ts, 5, 23))
|
||||
}
|
||||
interface Function<T> {
|
||||
>Function : Symbol(Function, Decl(working.ts, 1, 21), Decl(working.ts, 4, 5))
|
||||
>T : Symbol(T, Decl(working.ts, 2, 23), Decl(working.ts, 5, 23))
|
||||
|
||||
unary(): Function<() => ReturnType<T>>;
|
||||
>unary : Symbol(Function.unary, Decl(working.ts, 5, 27))
|
||||
>Function : Symbol(Function, Decl(working.ts, 1, 21), Decl(working.ts, 4, 5))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(working.ts, 2, 23), Decl(working.ts, 5, 23))
|
||||
}
|
||||
}
|
||||
=== tests/cases/compiler/regression.ts ===
|
||||
export namespace ns {
|
||||
>ns : Symbol(ns, Decl(regression.ts, 0, 0))
|
||||
|
||||
interface Function<T> {
|
||||
>Function : Symbol(Function, Decl(regression.ts, 0, 21), Decl(regression.ts, 3, 5))
|
||||
>T : Symbol(T, Decl(regression.ts, 1, 23), Decl(regression.ts, 4, 23))
|
||||
|
||||
unary(): Function<() => ReturnType<T>>;
|
||||
>unary : Symbol(Function.unary, Decl(regression.ts, 1, 27))
|
||||
>Function : Symbol(Function, Decl(regression.ts, 0, 21), Decl(regression.ts, 3, 5))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(regression.ts, 1, 23), Decl(regression.ts, 4, 23))
|
||||
}
|
||||
interface Function<T extends (...args: any) => any> {
|
||||
>Function : Symbol(Function, Decl(regression.ts, 0, 21), Decl(regression.ts, 3, 5))
|
||||
>T : Symbol(T, Decl(regression.ts, 1, 23), Decl(regression.ts, 4, 23))
|
||||
>args : Symbol(args, Decl(regression.ts, 4, 34))
|
||||
|
||||
throttle(): Function<T>;
|
||||
>throttle : Symbol(Function.throttle, Decl(regression.ts, 4, 57))
|
||||
>Function : Symbol(Function, Decl(regression.ts, 0, 21), Decl(regression.ts, 3, 5))
|
||||
>T : Symbol(T, Decl(regression.ts, 1, 23), Decl(regression.ts, 4, 23))
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
=== tests/cases/compiler/working.ts ===
|
||||
// minmal samples from #33395
|
||||
export namespace ns {
|
||||
interface Function<T extends (...args: any) => any> {
|
||||
>args : any
|
||||
|
||||
throttle(): Function<T>;
|
||||
>throttle : () => Function<T>
|
||||
}
|
||||
interface Function<T> {
|
||||
unary(): Function<() => ReturnType<T>>;
|
||||
>unary : () => Function<() => ReturnType<T>>
|
||||
}
|
||||
}
|
||||
=== tests/cases/compiler/regression.ts ===
|
||||
export namespace ns {
|
||||
interface Function<T> {
|
||||
unary(): Function<() => ReturnType<T>>;
|
||||
>unary : () => Function<() => ReturnType<T>>
|
||||
}
|
||||
interface Function<T extends (...args: any) => any> {
|
||||
>args : any
|
||||
|
||||
throttle(): Function<T>;
|
||||
>throttle : () => Function<T>
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'.
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
export var x;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
|
||||
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
|
||||
tests/cases/compiler/a.js(2,8): error TS8009: '?' can only be used in a .ts file.
|
||||
tests/cases/compiler/a.js(4,8): error TS8009: '?' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
|
||||
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
|
||||
==== tests/cases/compiler/a.js (2 errors) ====
|
||||
class C {
|
||||
foo?() {
|
||||
~
|
||||
!!! error TS8009: '?' can only be used in a .ts file.
|
||||
}
|
||||
bar? = 1;
|
||||
~
|
||||
!!! error TS8009: '?' can only be used in a .ts file.
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
|
||||
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
|
||||
tests/cases/compiler/a.js(1,5): error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
tests/cases/compiler/a.jsx(1,5): error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
tests/cases/compiler/a.jsx(2,5): error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
tests/cases/compiler/a.jsx(3,6): error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
tests/cases/compiler/a.jsx(4,6): error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
|
||||
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
==== tests/cases/compiler/a.jsx (4 errors) ====
|
||||
Foo<number>();
|
||||
~~~~~~
|
||||
!!! error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
Foo<number>``;
|
||||
~~~~~~
|
||||
!!! error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
<Foo<number>></Foo>;
|
||||
~~~~~~
|
||||
!!! error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
<Foo<number>/>;
|
||||
~~~~~~
|
||||
!!! error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [a.jsx]
|
||||
Foo<number>();
|
||||
Foo<number>``;
|
||||
<Foo<number>></Foo>;
|
||||
<Foo<number>/>;
|
||||
|
||||
//// [a.js]
|
||||
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
||||
return cooked;
|
||||
};
|
||||
Foo();
|
||||
Foo(__makeTemplateObject([""], [""]));
|
||||
<Foo></Foo>;
|
||||
<Foo />;
|
||||
@@ -1,3 +0,0 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
Foo<number>();
|
||||
No type information for this code.
|
||||
@@ -1,5 +0,0 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
Foo<number>();
|
||||
>Foo<number>() : any
|
||||
>Foo : any
|
||||
|
||||
@@ -256,7 +256,7 @@ const v5 = v && v;
|
||||
>v5 : void
|
||||
>v && v : void
|
||||
>v : void
|
||||
>v : never
|
||||
>v : void
|
||||
|
||||
const v6 = v && u;
|
||||
>v6 : void
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(3,5): error TS1164: Computed property names are not allowed in enums.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(3,11): error TS2304: Cannot find name 'id'.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(4,5): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(4,5): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(4,5): error TS1164: Computed property names are not allowed in enums.
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP
|
||||
!!! error TS2304: Cannot find name 'id'.
|
||||
[e2] = 1
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~~~~
|
||||
!!! error TS1164: Computed property names are not allowed in enums.
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(2,12): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(2,12): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(2,14): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,15): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,15): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,17): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,24): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,24): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,26): error TS2452: An enum member cannot have a numeric name.
|
||||
|
||||
|
||||
@@ -10,15 +10,15 @@ tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,26)
|
||||
enum E2 { a, }
|
||||
enum E3 { a: 1, }
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
enum E1 { a, b: 1, c, d: 2 = 3 }
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [reverseMappedTypeAssignableToIndex.ts]
|
||||
// Simple mapped type and inferrence
|
||||
type Mapped<T> = { [K in keyof T]: { name: T[K] } };
|
||||
type InferFromMapped<T> = T extends Mapped<infer R> ? R : never;
|
||||
|
||||
// Object literal type and associated mapped type
|
||||
// Note that in the real code we don't have a direct reference to LiteralType
|
||||
type LiteralType = {
|
||||
first: "first";
|
||||
second: "second";
|
||||
}
|
||||
type MappedLiteralType = {
|
||||
first: { name: "first" },
|
||||
second: { name: "second" },
|
||||
};
|
||||
|
||||
type Inferred = InferFromMapped<MappedLiteralType>;
|
||||
|
||||
// UNEXPECTED resolves to false
|
||||
type Test1 = Inferred extends Record<any, string> ? true : false;
|
||||
|
||||
//// [reverseMappedTypeAssignableToIndex.js]
|
||||
@@ -0,0 +1,54 @@
|
||||
=== tests/cases/compiler/reverseMappedTypeAssignableToIndex.ts ===
|
||||
// Simple mapped type and inferrence
|
||||
type Mapped<T> = { [K in keyof T]: { name: T[K] } };
|
||||
>Mapped : Symbol(Mapped, Decl(reverseMappedTypeAssignableToIndex.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(reverseMappedTypeAssignableToIndex.ts, 1, 12))
|
||||
>K : Symbol(K, Decl(reverseMappedTypeAssignableToIndex.ts, 1, 20))
|
||||
>T : Symbol(T, Decl(reverseMappedTypeAssignableToIndex.ts, 1, 12))
|
||||
>name : Symbol(name, Decl(reverseMappedTypeAssignableToIndex.ts, 1, 36))
|
||||
>T : Symbol(T, Decl(reverseMappedTypeAssignableToIndex.ts, 1, 12))
|
||||
>K : Symbol(K, Decl(reverseMappedTypeAssignableToIndex.ts, 1, 20))
|
||||
|
||||
type InferFromMapped<T> = T extends Mapped<infer R> ? R : never;
|
||||
>InferFromMapped : Symbol(InferFromMapped, Decl(reverseMappedTypeAssignableToIndex.ts, 1, 52))
|
||||
>T : Symbol(T, Decl(reverseMappedTypeAssignableToIndex.ts, 2, 21))
|
||||
>T : Symbol(T, Decl(reverseMappedTypeAssignableToIndex.ts, 2, 21))
|
||||
>Mapped : Symbol(Mapped, Decl(reverseMappedTypeAssignableToIndex.ts, 0, 0))
|
||||
>R : Symbol(R, Decl(reverseMappedTypeAssignableToIndex.ts, 2, 48))
|
||||
>R : Symbol(R, Decl(reverseMappedTypeAssignableToIndex.ts, 2, 48))
|
||||
|
||||
// Object literal type and associated mapped type
|
||||
// Note that in the real code we don't have a direct reference to LiteralType
|
||||
type LiteralType = {
|
||||
>LiteralType : Symbol(LiteralType, Decl(reverseMappedTypeAssignableToIndex.ts, 2, 64))
|
||||
|
||||
first: "first";
|
||||
>first : Symbol(first, Decl(reverseMappedTypeAssignableToIndex.ts, 6, 20))
|
||||
|
||||
second: "second";
|
||||
>second : Symbol(second, Decl(reverseMappedTypeAssignableToIndex.ts, 7, 16))
|
||||
}
|
||||
type MappedLiteralType = {
|
||||
>MappedLiteralType : Symbol(MappedLiteralType, Decl(reverseMappedTypeAssignableToIndex.ts, 9, 1))
|
||||
|
||||
first: { name: "first" },
|
||||
>first : Symbol(first, Decl(reverseMappedTypeAssignableToIndex.ts, 10, 26))
|
||||
>name : Symbol(name, Decl(reverseMappedTypeAssignableToIndex.ts, 11, 9))
|
||||
|
||||
second: { name: "second" },
|
||||
>second : Symbol(second, Decl(reverseMappedTypeAssignableToIndex.ts, 11, 26))
|
||||
>name : Symbol(name, Decl(reverseMappedTypeAssignableToIndex.ts, 12, 10))
|
||||
|
||||
};
|
||||
|
||||
type Inferred = InferFromMapped<MappedLiteralType>;
|
||||
>Inferred : Symbol(Inferred, Decl(reverseMappedTypeAssignableToIndex.ts, 13, 2))
|
||||
>InferFromMapped : Symbol(InferFromMapped, Decl(reverseMappedTypeAssignableToIndex.ts, 1, 52))
|
||||
>MappedLiteralType : Symbol(MappedLiteralType, Decl(reverseMappedTypeAssignableToIndex.ts, 9, 1))
|
||||
|
||||
// UNEXPECTED resolves to false
|
||||
type Test1 = Inferred extends Record<any, string> ? true : false;
|
||||
>Test1 : Symbol(Test1, Decl(reverseMappedTypeAssignableToIndex.ts, 15, 51))
|
||||
>Inferred : Symbol(Inferred, Decl(reverseMappedTypeAssignableToIndex.ts, 13, 2))
|
||||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
=== tests/cases/compiler/reverseMappedTypeAssignableToIndex.ts ===
|
||||
// Simple mapped type and inferrence
|
||||
type Mapped<T> = { [K in keyof T]: { name: T[K] } };
|
||||
>Mapped : Mapped<T>
|
||||
>name : T[K]
|
||||
|
||||
type InferFromMapped<T> = T extends Mapped<infer R> ? R : never;
|
||||
>InferFromMapped : InferFromMapped<T>
|
||||
|
||||
// Object literal type and associated mapped type
|
||||
// Note that in the real code we don't have a direct reference to LiteralType
|
||||
type LiteralType = {
|
||||
>LiteralType : LiteralType
|
||||
|
||||
first: "first";
|
||||
>first : "first"
|
||||
|
||||
second: "second";
|
||||
>second : "second"
|
||||
}
|
||||
type MappedLiteralType = {
|
||||
>MappedLiteralType : MappedLiteralType
|
||||
|
||||
first: { name: "first" },
|
||||
>first : { name: "first"; }
|
||||
>name : "first"
|
||||
|
||||
second: { name: "second" },
|
||||
>second : { name: "second"; }
|
||||
>name : "second"
|
||||
|
||||
};
|
||||
|
||||
type Inferred = InferFromMapped<MappedLiteralType>;
|
||||
>Inferred : { first: "first"; second: "second"; }
|
||||
|
||||
// UNEXPECTED resolves to false
|
||||
type Test1 = Inferred extends Record<any, string> ? true : false;
|
||||
>Test1 : true
|
||||
>true : true
|
||||
>false : false
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
var Foo = /** @class */ (function () {
|
||||
function Foo(x) {
|
||||
this.x = x;
|
||||
}
|
||||
Foo = __decorate([
|
||||
__param(0, Dec)
|
||||
], Foo);
|
||||
return Foo;
|
||||
}());
|
||||
+3
@@ -332,6 +332,9 @@ declare const myVar = 30;
|
||||
//// [/src/lib/file1.ts]
|
||||
export const x = 10;console.log(x);
|
||||
|
||||
//// [/src/lib/module.d.ts] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/lib/module.js]
|
||||
var myGlob = 20;
|
||||
define("file1", ["require", "exports"], function (require, exports) {
|
||||
|
||||
+3
@@ -790,6 +790,9 @@ export const x = 10;function forlibfile1Rest() {
|
||||
const { b, ...rest } = { a: 10, b: 30, yy: 30 };
|
||||
}console.log(x);
|
||||
|
||||
//// [/src/lib/module.d.ts] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/lib/module.js]
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
|
||||
+3
@@ -482,6 +482,9 @@ declare const myVar = 30;
|
||||
//// [/src/lib/file1.ts]
|
||||
export const x = 10;console.log(x);
|
||||
|
||||
//// [/src/lib/module.d.ts] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/lib/module.js]
|
||||
"use strict";
|
||||
"myPrologue";
|
||||
|
||||
+3
@@ -338,6 +338,9 @@ declare const myVar = 30;
|
||||
#!someshebang lib file1
|
||||
export const x = 10;console.log(x);
|
||||
|
||||
//// [/src/lib/module.d.ts] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/lib/module.js]
|
||||
#!someshebang lib file0
|
||||
var myGlob = 20;
|
||||
|
||||
+3
@@ -1893,6 +1893,9 @@ export namespace normalN {
|
||||
/*@internal*/ export const internalConst = 10;
|
||||
/*@internal*/ export enum internalEnum { a, b, c }console.log(x);
|
||||
|
||||
//// [/src/lib/module.d.ts] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/lib/module.js]
|
||||
/*@internal*/ var myGlob = 20;
|
||||
define("file1", ["require", "exports"], function (require, exports) {
|
||||
|
||||
+3
@@ -432,6 +432,9 @@ declare const myVar = 30;
|
||||
//// [/src/lib/file1.ts]
|
||||
export const x = 10;console.log(x);
|
||||
|
||||
//// [/src/lib/module.d.ts] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/lib/module.js]
|
||||
///<reference path="./tripleRef.d.ts"/>
|
||||
var file0Const = new libfile0();
|
||||
|
||||
+3
@@ -724,6 +724,9 @@ declare function appfile4Spread(...b: number[]): void;
|
||||
//// [/src/lib/file1.ts]
|
||||
export const x = 10;function forlibfile1Rest() { }
|
||||
|
||||
//// [/src/lib/module.d.ts] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/lib/module.js]
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
|
||||
+1
@@ -647,6 +647,7 @@ declare const myVar = 30;
|
||||
"myPrologue5"
|
||||
export const x = 10;
|
||||
|
||||
//// [/src/lib/module.d.ts] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map]
|
||||
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["file0.ts","file1.ts","file2.ts","global.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM,KAAK,CAAC;;ICAlB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;;ICApB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,WAAW,KAAK,CAAC"}
|
||||
|
||||
|
||||
+1
@@ -2071,6 +2071,7 @@ export namespace normalN {
|
||||
/*@internal*/ export const internalConst = 10;
|
||||
/*@internal*/ export enum internalEnum { a, b, c }
|
||||
|
||||
//// [/src/lib/module.d.ts] file written with same contents
|
||||
//// [/src/lib/module.d.ts.map]
|
||||
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["file0.ts","file1.ts","file2.ts","global.ts"],"names":[],"mappings":"AAAc,QAAA,MAAM,MAAM,KAAK,CAAC;;ICAlB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;IAClC,MAAM,OAAO,OAAO;;QAEF,IAAI,EAAE,MAAM,CAAC;QACb,MAAM;sBACF,CAAC,EACM,MAAM;KAClC;IACD,MAAM,WAAW,OAAO,CAAC;QACP,MAAa,CAAC;SAAI;QAClB,SAAgB,GAAG,SAAK;QACxB,UAAiB,aAAa,CAAC;YAAE,MAAa,CAAC;aAAG;SAAE;QACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;YAAE,MAAa,SAAS;aAAG;SAAE;QAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;QAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;QAC9B,MAAM,aAAa,KAAK,CAAC;QAChC,KAAY,YAAY;YAAG,CAAC,IAAA;YAAE,CAAC,IAAA;YAAE,CAAC,IAAA;SAAE;KACrD;IACa,MAAM,OAAO,SAAS;KAAG;IACzB,MAAM,UAAU,WAAW,SAAK;IAChC,MAAM,WAAW,iBAAiB,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAChE,MAAM,WAAW,aAAa,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IACtE,MAAM,QAAQ,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAC3D,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,MAAM,aAAa,KAAK,CAAC;IAChC,MAAM,MAAM,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;;;ICzBlD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,WAAW,KAAK,CAAC"}
|
||||
|
||||
|
||||
+266
@@ -521,6 +521,123 @@ declare const globalConst = 10;
|
||||
//// [/src/module.d.ts.map]
|
||||
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["lib/file0.ts","lib/file1.ts","lib/file2.ts","lib/global.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,MAAM,KAAK,CAAC;;ICAlB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;;ICApB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,WAAW,KAAK,CAAC"}
|
||||
|
||||
//// [/src/module.d.ts.map.baseline.txt]
|
||||
===================================================================
|
||||
JsFile: module.d.ts
|
||||
mapUrl: module.d.ts.map
|
||||
sourceRoot:
|
||||
sources: lib/file0.ts,lib/file1.ts,lib/file2.ts,lib/global.ts
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:/src/module.d.ts
|
||||
sourceFile:lib/file0.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>declare const myGlob = 20;
|
||||
1 >
|
||||
2 >^^^^^^^^
|
||||
3 > ^^^^^^
|
||||
4 > ^^^^^^
|
||||
5 > ^^^^^
|
||||
6 > ^
|
||||
7 > ^^^->
|
||||
1 >
|
||||
2 >
|
||||
3 > const
|
||||
4 > myGlob
|
||||
5 > = 20
|
||||
6 > ;
|
||||
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
|
||||
2 >Emitted(1, 9) Source(1, 1) + SourceIndex(0)
|
||||
3 >Emitted(1, 15) Source(1, 7) + SourceIndex(0)
|
||||
4 >Emitted(1, 21) Source(1, 13) + SourceIndex(0)
|
||||
5 >Emitted(1, 26) Source(1, 18) + SourceIndex(0)
|
||||
6 >Emitted(1, 27) Source(1, 19) + SourceIndex(0)
|
||||
---
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:/src/module.d.ts
|
||||
sourceFile:lib/file1.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>declare module "lib/file1" {
|
||||
>>> export const x = 10;
|
||||
1->^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^
|
||||
5 > ^
|
||||
6 > ^^^^^
|
||||
7 > ^
|
||||
1->
|
||||
2 > export
|
||||
3 >
|
||||
4 > const
|
||||
5 > x
|
||||
6 > = 10
|
||||
7 > ;
|
||||
1->Emitted(3, 5) Source(1, 1) + SourceIndex(1)
|
||||
2 >Emitted(3, 11) Source(1, 7) + SourceIndex(1)
|
||||
3 >Emitted(3, 12) Source(1, 8) + SourceIndex(1)
|
||||
4 >Emitted(3, 18) Source(1, 14) + SourceIndex(1)
|
||||
5 >Emitted(3, 19) Source(1, 15) + SourceIndex(1)
|
||||
6 >Emitted(3, 24) Source(1, 20) + SourceIndex(1)
|
||||
7 >Emitted(3, 25) Source(1, 21) + SourceIndex(1)
|
||||
---
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:/src/module.d.ts
|
||||
sourceFile:lib/file2.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>}
|
||||
>>>declare module "lib/file2" {
|
||||
>>> export const y = 20;
|
||||
1 >^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^
|
||||
5 > ^
|
||||
6 > ^^^^^
|
||||
7 > ^
|
||||
1 >
|
||||
2 > export
|
||||
3 >
|
||||
4 > const
|
||||
5 > y
|
||||
6 > = 20
|
||||
7 > ;
|
||||
1 >Emitted(6, 5) Source(1, 1) + SourceIndex(2)
|
||||
2 >Emitted(6, 11) Source(1, 7) + SourceIndex(2)
|
||||
3 >Emitted(6, 12) Source(1, 8) + SourceIndex(2)
|
||||
4 >Emitted(6, 18) Source(1, 14) + SourceIndex(2)
|
||||
5 >Emitted(6, 19) Source(1, 15) + SourceIndex(2)
|
||||
6 >Emitted(6, 24) Source(1, 20) + SourceIndex(2)
|
||||
7 >Emitted(6, 25) Source(1, 21) + SourceIndex(2)
|
||||
---
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:/src/module.d.ts
|
||||
sourceFile:lib/global.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>}
|
||||
>>>declare const globalConst = 10;
|
||||
1 >
|
||||
2 >^^^^^^^^
|
||||
3 > ^^^^^^
|
||||
4 > ^^^^^^^^^^^
|
||||
5 > ^^^^^
|
||||
6 > ^
|
||||
7 > ^^^^->
|
||||
1 >
|
||||
2 >
|
||||
3 > const
|
||||
4 > globalConst
|
||||
5 > = 10
|
||||
6 > ;
|
||||
1 >Emitted(8, 1) Source(1, 1) + SourceIndex(3)
|
||||
2 >Emitted(8, 9) Source(1, 1) + SourceIndex(3)
|
||||
3 >Emitted(8, 15) Source(1, 7) + SourceIndex(3)
|
||||
4 >Emitted(8, 26) Source(1, 18) + SourceIndex(3)
|
||||
5 >Emitted(8, 31) Source(1, 23) + SourceIndex(3)
|
||||
6 >Emitted(8, 32) Source(1, 24) + SourceIndex(3)
|
||||
---
|
||||
>>>//# sourceMappingURL=module.d.ts.map
|
||||
|
||||
//// [/src/module.js]
|
||||
var myGlob = 20;
|
||||
define("lib/file1", ["require", "exports"], function (require, exports) {
|
||||
@@ -539,6 +656,121 @@ var globalConst = 10;
|
||||
//// [/src/module.js.map]
|
||||
{"version":3,"file":"module.js","sourceRoot":"","sources":["lib/file0.ts","lib/file1.ts","lib/file2.ts","lib/global.ts"],"names":[],"mappings":"AAAA,IAAM,MAAM,GAAG,EAAE,CAAC;;;;ICAL,QAAA,CAAC,GAAG,EAAE,CAAC;;;;;ICAP,QAAA,CAAC,GAAG,EAAE,CAAC;;ACApB,IAAM,WAAW,GAAG,EAAE,CAAC"}
|
||||
|
||||
//// [/src/module.js.map.baseline.txt]
|
||||
===================================================================
|
||||
JsFile: module.js
|
||||
mapUrl: module.js.map
|
||||
sourceRoot:
|
||||
sources: lib/file0.ts,lib/file1.ts,lib/file2.ts,lib/global.ts
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:/src/module.js
|
||||
sourceFile:lib/file0.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>var myGlob = 20;
|
||||
1 >
|
||||
2 >^^^^
|
||||
3 > ^^^^^^
|
||||
4 > ^^^
|
||||
5 > ^^
|
||||
6 > ^
|
||||
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
2 >const
|
||||
3 > myGlob
|
||||
4 > =
|
||||
5 > 20
|
||||
6 > ;
|
||||
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
|
||||
2 >Emitted(1, 5) Source(1, 7) + SourceIndex(0)
|
||||
3 >Emitted(1, 11) Source(1, 13) + SourceIndex(0)
|
||||
4 >Emitted(1, 14) Source(1, 16) + SourceIndex(0)
|
||||
5 >Emitted(1, 16) Source(1, 18) + SourceIndex(0)
|
||||
6 >Emitted(1, 17) Source(1, 19) + SourceIndex(0)
|
||||
---
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:/src/module.js
|
||||
sourceFile:lib/file1.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>define("lib/file1", ["require", "exports"], function (require, exports) {
|
||||
>>> "use strict";
|
||||
>>> Object.defineProperty(exports, "__esModule", { value: true });
|
||||
>>> exports.x = 10;
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^
|
||||
5 > ^^
|
||||
6 > ^
|
||||
1->export const
|
||||
2 >
|
||||
3 > x
|
||||
4 > =
|
||||
5 > 10
|
||||
6 > ;
|
||||
1->Emitted(5, 5) Source(1, 14) + SourceIndex(1)
|
||||
2 >Emitted(5, 13) Source(1, 14) + SourceIndex(1)
|
||||
3 >Emitted(5, 14) Source(1, 15) + SourceIndex(1)
|
||||
4 >Emitted(5, 17) Source(1, 18) + SourceIndex(1)
|
||||
5 >Emitted(5, 19) Source(1, 20) + SourceIndex(1)
|
||||
6 >Emitted(5, 20) Source(1, 21) + SourceIndex(1)
|
||||
---
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:/src/module.js
|
||||
sourceFile:lib/file2.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>});
|
||||
>>>define("lib/file2", ["require", "exports"], function (require, exports) {
|
||||
>>> "use strict";
|
||||
>>> Object.defineProperty(exports, "__esModule", { value: true });
|
||||
>>> exports.y = 20;
|
||||
1 >^^^^
|
||||
2 > ^^^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^
|
||||
5 > ^^
|
||||
6 > ^
|
||||
1 >export const
|
||||
2 >
|
||||
3 > y
|
||||
4 > =
|
||||
5 > 20
|
||||
6 > ;
|
||||
1 >Emitted(10, 5) Source(1, 14) + SourceIndex(2)
|
||||
2 >Emitted(10, 13) Source(1, 14) + SourceIndex(2)
|
||||
3 >Emitted(10, 14) Source(1, 15) + SourceIndex(2)
|
||||
4 >Emitted(10, 17) Source(1, 18) + SourceIndex(2)
|
||||
5 >Emitted(10, 19) Source(1, 20) + SourceIndex(2)
|
||||
6 >Emitted(10, 20) Source(1, 21) + SourceIndex(2)
|
||||
---
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:/src/module.js
|
||||
sourceFile:lib/global.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>});
|
||||
>>>var globalConst = 10;
|
||||
1 >
|
||||
2 >^^^^
|
||||
3 > ^^^^^^^^^^^
|
||||
4 > ^^^
|
||||
5 > ^^
|
||||
6 > ^
|
||||
7 > ^^^^^^^^^^^^->
|
||||
1 >
|
||||
2 >const
|
||||
3 > globalConst
|
||||
4 > =
|
||||
5 > 10
|
||||
6 > ;
|
||||
1 >Emitted(12, 1) Source(1, 1) + SourceIndex(3)
|
||||
2 >Emitted(12, 5) Source(1, 7) + SourceIndex(3)
|
||||
3 >Emitted(12, 16) Source(1, 18) + SourceIndex(3)
|
||||
4 >Emitted(12, 19) Source(1, 21) + SourceIndex(3)
|
||||
5 >Emitted(12, 21) Source(1, 23) + SourceIndex(3)
|
||||
6 >Emitted(12, 22) Source(1, 24) + SourceIndex(3)
|
||||
---
|
||||
>>>//# sourceMappingURL=module.js.map
|
||||
|
||||
//// [/src/module.tsbuildinfo]
|
||||
{
|
||||
"bundle": {
|
||||
@@ -571,3 +803,37 @@ var globalConst = 10;
|
||||
"version": "FakeTSVersion"
|
||||
}
|
||||
|
||||
//// [/src/module.tsbuildinfo.baseline.txt]
|
||||
======================================================================
|
||||
File:: /src/module.js
|
||||
----------------------------------------------------------------------
|
||||
text: (0-417)
|
||||
var myGlob = 20;
|
||||
define("lib/file1", ["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.x = 10;
|
||||
});
|
||||
define("lib/file2", ["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.y = 20;
|
||||
});
|
||||
var globalConst = 10;
|
||||
|
||||
======================================================================
|
||||
======================================================================
|
||||
File:: /src/module.d.ts
|
||||
----------------------------------------------------------------------
|
||||
text: (0-179)
|
||||
declare const myGlob = 20;
|
||||
declare module "lib/file1" {
|
||||
export const x = 10;
|
||||
}
|
||||
declare module "lib/file2" {
|
||||
export const y = 20;
|
||||
}
|
||||
declare const globalConst = 10;
|
||||
|
||||
======================================================================
|
||||
|
||||
+6
@@ -9,6 +9,12 @@ export interface A {
|
||||
//// [/src/lib/a.d.ts.map]
|
||||
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../src/a.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,CAAC;IAChB,CAAC,EAAE,CAAC,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;CAChB"}
|
||||
|
||||
//// [/src/lib/b.d.ts] file written with same contents
|
||||
//// [/src/lib/b.d.ts.map] file written with same contents
|
||||
//// [/src/lib/c.d.ts] file written with same contents
|
||||
//// [/src/lib/c.d.ts.map] file written with same contents
|
||||
//// [/src/lib/index.d.ts] file written with same contents
|
||||
//// [/src/lib/index.d.ts.map] file written with same contents
|
||||
//// [/src/src/a.ts]
|
||||
import { B } from "./b";
|
||||
|
||||
|
||||
+3
@@ -6,6 +6,9 @@ export interface A {
|
||||
}
|
||||
|
||||
|
||||
//// [/src/lib/b.d.ts] file written with same contents
|
||||
//// [/src/lib/c.d.ts] file written with same contents
|
||||
//// [/src/lib/index.d.ts] file written with same contents
|
||||
//// [/src/src/a.ts]
|
||||
import { B } from "./b";
|
||||
|
||||
|
||||
+4
@@ -11,6 +11,10 @@ export interface A {
|
||||
//// [/src/lib/a.d.ts.map]
|
||||
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../src/a.ts"],"names":[],"mappings":"AAAA,qBAAa,CAAC;IAAG,IAAI,SAAW;CAAE;AAElC,MAAM,WAAW,CAAC;IAChB,CAAC,EAAE,CAAC,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;CAChB"}
|
||||
|
||||
//// [/src/lib/b.d.ts] file written with same contents
|
||||
//// [/src/lib/b.d.ts.map] file written with same contents
|
||||
//// [/src/lib/c.d.ts] file written with same contents
|
||||
//// [/src/lib/c.d.ts.map] file written with same contents
|
||||
//// [/src/src/a.ts]
|
||||
export class B { prop = "hello"; }
|
||||
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//// [/src/lib/a.d.ts] file written with same contents
|
||||
//// [/src/lib/a.d.ts.map]
|
||||
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../src/a.ts"],"names":[],"mappings":"AAAA,qBAAa,CAAC;IAAG,IAAI,SAAW;CAAE;AAGlC,MAAM,WAAW,CAAC;IAChB,CAAC,EAAE,CAAC,CAAC;CACN"}
|
||||
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
//// [/src/bar.ts]
|
||||
interface RawAction {
|
||||
(...args: any[]): Promise<any> | void;
|
||||
}
|
||||
interface ActionFactory {
|
||||
<T extends RawAction>(target: T): T;
|
||||
}
|
||||
declare function foo<U extends any[] = any[]>(): ActionFactory;
|
||||
export default foo()(function foobar(): void {
|
||||
});
|
||||
|
||||
//// [/src/obj/bar.d.ts]
|
||||
declare const _default: () => void;
|
||||
export default _default;
|
||||
|
||||
|
||||
//// [/src/obj/bar.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = foo()(function foobar() {
|
||||
});
|
||||
|
||||
|
||||
//// [/src/obj/index.d.ts]
|
||||
import { LazyAction } from './bundling';
|
||||
export declare const lazyBar: LazyAction<() => void, typeof import("./lazyIndex")>;
|
||||
|
||||
|
||||
//// [/src/obj/lazyIndex.d.ts] file written with same contents
|
||||
//// [/src/obj/tsconfig.tsbuildinfo]
|
||||
{
|
||||
"program": {
|
||||
"fileInfos": {
|
||||
"../../lib/lib.d.ts": {
|
||||
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
|
||||
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };"
|
||||
},
|
||||
"../bar.ts": {
|
||||
"version": "747071916-interface RawAction {\r\n (...args: any[]): Promise<any> | void;\r\n}\r\ninterface ActionFactory {\r\n <T extends RawAction>(target: T): T;\r\n}\r\ndeclare function foo<U extends any[] = any[]>(): ActionFactory;\r\nexport default foo()(function foobar(): void {\r\n});",
|
||||
"signature": "-9232740537-declare const _default: () => void;\r\nexport default _default;\r\n"
|
||||
},
|
||||
"../bundling.ts": {
|
||||
"version": "-21659820217-export class LazyModule<TModule> {\r\n constructor(private importCallback: () => Promise<TModule>) {}\r\n}\r\n\r\nexport class LazyAction<\r\n TAction extends (...args: any[]) => any,\r\n TModule\r\n> {\r\n constructor(_lazyModule: LazyModule<TModule>, _getter: (module: TModule) => TAction) {\r\n }\r\n}\r\n",
|
||||
"signature": "-40032907372-export declare class LazyModule<TModule> {\r\n private importCallback;\r\n constructor(importCallback: () => Promise<TModule>);\r\n}\r\nexport declare class LazyAction<TAction extends (...args: any[]) => any, TModule> {\r\n constructor(_lazyModule: LazyModule<TModule>, _getter: (module: TModule) => TAction);\r\n}\r\n"
|
||||
},
|
||||
"../global.d.ts": {
|
||||
"version": "-9780226215-interface PromiseConstructor {\r\n new <T>(): Promise<T>;\r\n}\r\ndeclare var Promise: PromiseConstructor;\r\ninterface Promise<T> {\r\n}",
|
||||
"signature": "-9780226215-interface PromiseConstructor {\r\n new <T>(): Promise<T>;\r\n}\r\ndeclare var Promise: PromiseConstructor;\r\ninterface Promise<T> {\r\n}"
|
||||
},
|
||||
"../lazyindex.ts": {
|
||||
"version": "-6956449754-export { default as bar } from './bar';\n",
|
||||
"signature": "-6224542381-export { default as bar } from './bar';\r\n"
|
||||
},
|
||||
"../index.ts": {
|
||||
"version": "-11602502901-import { LazyAction, LazyModule } from './bundling';\r\nconst lazyModule = new LazyModule(() =>\r\n import('./lazyIndex')\r\n);\r\nexport const lazyBar = new LazyAction(lazyModule, m => m.bar);",
|
||||
"signature": "6256067474-import { LazyAction } from './bundling';\r\nexport declare const lazyBar: LazyAction<() => void, typeof import(\"./lazyIndex\")>;\r\n"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"target": 1,
|
||||
"declaration": true,
|
||||
"outDir": "./",
|
||||
"incremental": true,
|
||||
"isolatedModules": true,
|
||||
"configFilePath": "../tsconfig.json"
|
||||
},
|
||||
"referencedMap": {
|
||||
"../index.ts": [
|
||||
"../bundling.ts",
|
||||
"../lazyindex.ts"
|
||||
],
|
||||
"../lazyindex.ts": [
|
||||
"../bar.ts"
|
||||
]
|
||||
},
|
||||
"exportedModulesMap": {
|
||||
"../index.ts": [
|
||||
"../bundling.ts",
|
||||
"../lazyindex.ts"
|
||||
],
|
||||
"../lazyindex.ts": [
|
||||
"../bar.ts"
|
||||
]
|
||||
},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../../lib/lib.d.ts",
|
||||
"../bar.ts",
|
||||
"../bundling.ts",
|
||||
"../global.d.ts",
|
||||
"../index.ts",
|
||||
"../lazyindex.ts"
|
||||
]
|
||||
},
|
||||
"version": "FakeTSVersion"
|
||||
}
|
||||
|
||||
+2
@@ -26,6 +26,8 @@ import { LazyAction } from './bundling';
|
||||
export declare const lazyBar: LazyAction<() => void, typeof import("./lazyIndex")>;
|
||||
|
||||
|
||||
//// [/src/obj/lazyIndex.d.ts] file written with same contents
|
||||
//// [/src/obj/lazyIndex.js] file written with same contents
|
||||
//// [/src/obj/tsconfig.tsbuildinfo]
|
||||
{
|
||||
"program": {
|
||||
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
//// [/src/obj/bar.d.ts]
|
||||
declare const _default: (param: string) => void;
|
||||
export default _default;
|
||||
|
||||
|
||||
//// [/src/obj/bar.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = foo()(function foobar(param) {
|
||||
});
|
||||
|
||||
|
||||
//// [/src/obj/bundling.d.ts]
|
||||
export declare class LazyModule<TModule> {
|
||||
private importCallback;
|
||||
constructor(importCallback: () => Promise<TModule>);
|
||||
}
|
||||
export declare class LazyAction<TAction extends (...args: any[]) => any, TModule> {
|
||||
constructor(_lazyModule: LazyModule<TModule>, _getter: (module: TModule) => TAction);
|
||||
}
|
||||
|
||||
|
||||
//// [/src/obj/bundling.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var LazyModule = /** @class */ (function () {
|
||||
function LazyModule(importCallback) {
|
||||
this.importCallback = importCallback;
|
||||
}
|
||||
return LazyModule;
|
||||
}());
|
||||
exports.LazyModule = LazyModule;
|
||||
var LazyAction = /** @class */ (function () {
|
||||
function LazyAction(_lazyModule, _getter) {
|
||||
}
|
||||
return LazyAction;
|
||||
}());
|
||||
exports.LazyAction = LazyAction;
|
||||
|
||||
|
||||
//// [/src/obj/index.d.ts]
|
||||
import { LazyAction } from './bundling';
|
||||
export declare const lazyBar: LazyAction<(param: string) => void, typeof import("./lazyIndex")>;
|
||||
|
||||
|
||||
//// [/src/obj/index.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var bundling_1 = require("./bundling");
|
||||
var lazyModule = new bundling_1.LazyModule(function () {
|
||||
return Promise.resolve().then(function () { return require('./lazyIndex'); });
|
||||
});
|
||||
exports.lazyBar = new bundling_1.LazyAction(lazyModule, function (m) { return m.bar; });
|
||||
|
||||
|
||||
//// [/src/obj/lazyIndex.d.ts]
|
||||
export { default as bar } from './bar';
|
||||
|
||||
|
||||
//// [/src/obj/lazyIndex.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var bar_1 = require("./bar");
|
||||
exports.bar = bar_1.default;
|
||||
|
||||
|
||||
//// [/src/obj/tsconfig.tsbuildinfo]
|
||||
{
|
||||
"program": {
|
||||
"fileInfos": {
|
||||
"../../lib/lib.d.ts": {
|
||||
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
|
||||
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };"
|
||||
},
|
||||
"../bar.ts": {
|
||||
"version": "5936740878-interface RawAction {\r\n (...args: any[]): Promise<any> | void;\r\n}\r\ninterface ActionFactory {\r\n <T extends RawAction>(target: T): T;\r\n}\r\ndeclare function foo<U extends any[] = any[]>(): ActionFactory;\r\nexport default foo()(function foobar(param: string): void {\r\n});",
|
||||
"signature": "11191036521-declare const _default: (param: string) => void;\r\nexport default _default;\r\n"
|
||||
},
|
||||
"../bundling.ts": {
|
||||
"version": "-21659820217-export class LazyModule<TModule> {\r\n constructor(private importCallback: () => Promise<TModule>) {}\r\n}\r\n\r\nexport class LazyAction<\r\n TAction extends (...args: any[]) => any,\r\n TModule\r\n> {\r\n constructor(_lazyModule: LazyModule<TModule>, _getter: (module: TModule) => TAction) {\r\n }\r\n}\r\n",
|
||||
"signature": "-40032907372-export declare class LazyModule<TModule> {\r\n private importCallback;\r\n constructor(importCallback: () => Promise<TModule>);\r\n}\r\nexport declare class LazyAction<TAction extends (...args: any[]) => any, TModule> {\r\n constructor(_lazyModule: LazyModule<TModule>, _getter: (module: TModule) => TAction);\r\n}\r\n"
|
||||
},
|
||||
"../global.d.ts": {
|
||||
"version": "-9780226215-interface PromiseConstructor {\r\n new <T>(): Promise<T>;\r\n}\r\ndeclare var Promise: PromiseConstructor;\r\ninterface Promise<T> {\r\n}",
|
||||
"signature": "-9780226215-interface PromiseConstructor {\r\n new <T>(): Promise<T>;\r\n}\r\ndeclare var Promise: PromiseConstructor;\r\ninterface Promise<T> {\r\n}"
|
||||
},
|
||||
"../lazyindex.ts": {
|
||||
"version": "-6956449754-export { default as bar } from './bar';\n",
|
||||
"signature": "-6224542381-export { default as bar } from './bar';\r\n"
|
||||
},
|
||||
"../index.ts": {
|
||||
"version": "-11602502901-import { LazyAction, LazyModule } from './bundling';\r\nconst lazyModule = new LazyModule(() =>\r\n import('./lazyIndex')\r\n);\r\nexport const lazyBar = new LazyAction(lazyModule, m => m.bar);",
|
||||
"signature": "18468008756-import { LazyAction } from './bundling';\r\nexport declare const lazyBar: LazyAction<(param: string) => void, typeof import(\"./lazyIndex\")>;\r\n"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"target": 1,
|
||||
"declaration": true,
|
||||
"outDir": "./",
|
||||
"incremental": true,
|
||||
"isolatedModules": true,
|
||||
"configFilePath": "../tsconfig.json"
|
||||
},
|
||||
"referencedMap": {
|
||||
"../index.ts": [
|
||||
"../bundling.ts",
|
||||
"../lazyindex.ts"
|
||||
],
|
||||
"../lazyindex.ts": [
|
||||
"../bar.ts"
|
||||
]
|
||||
},
|
||||
"exportedModulesMap": {
|
||||
"../index.ts": [
|
||||
"../bundling.ts",
|
||||
"../lazyindex.ts"
|
||||
],
|
||||
"../lazyindex.ts": [
|
||||
"../bar.ts"
|
||||
]
|
||||
},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../../lib/lib.d.ts",
|
||||
"../bar.ts",
|
||||
"../bundling.ts",
|
||||
"../global.d.ts",
|
||||
"../index.ts",
|
||||
"../lazyindex.ts"
|
||||
]
|
||||
},
|
||||
"version": "FakeTSVersion"
|
||||
}
|
||||
|
||||
//// [/src/tsconfig.json]
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"declaration": true,
|
||||
"outDir": "obj",
|
||||
"incremental": true, "isolatedModules": true
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
//// [/src/first/bin/first-output.d.ts] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/first/bin/first-output.js]
|
||||
var s = "Hello, world";
|
||||
console.log(s);
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
//// [/src/first/bin/first-output.d.ts] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/first/bin/first-output.js]
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
//// [/src/first/bin/first-output.d.ts] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/first/bin/first-output.js]
|
||||
var s = "Hello, world";
|
||||
console.log(s);
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
//// [/src/first/bin/first-output.d.ts] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/first/bin/first-output.js]
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
//// [/src/first/bin/first-output.d.ts] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/first/bin/first-output.js]
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
//// [/src/first/bin/first-output.d.ts] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/first/bin/first-output.js]
|
||||
"use strict";
|
||||
"myPrologue";
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
//// [/src/first/bin/first-output.d.ts] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map] file written with same contents
|
||||
//// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents
|
||||
//// [/src/first/bin/first-output.js]
|
||||
"use strict";
|
||||
var s = "Hello, world";
|
||||
|
||||
Loaded 100 of 215 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user