Merge branch 'master' of https://github.com/Microsoft/TypeScript into bug/36989

This commit is contained in:
Alexander T
2020-02-27 09:50:54 +02:00
105 changed files with 1931 additions and 94 deletions
+18 -7
View File
@@ -298,6 +298,7 @@ namespace ts {
let typeCount = 0;
let symbolCount = 0;
let enumCount = 0;
let totalInstantiationCount = 0;
let instantiationCount = 0;
let instantiationDepth = 0;
let constraintDepth = 0;
@@ -348,6 +349,7 @@ namespace ts {
getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"),
getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount,
getTypeCount: () => typeCount,
getInstantiationCount: () => totalInstantiationCount,
getRelationCacheSizes: () => ({
assignable: assignableRelation.size,
identity: identityRelation.size,
@@ -13775,6 +13777,7 @@ namespace ts {
error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
return errorType;
}
totalInstantiationCount++;
instantiationCount++;
instantiationDepth++;
const result = instantiateTypeWorker(type, mapper);
@@ -20519,12 +20522,20 @@ namespace ts {
/** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */
function removeOptionalityFromDeclaredType(declaredType: Type, declaration: VariableLikeDeclaration): Type {
const annotationIncludesUndefined = strictNullChecks &&
declaration.kind === SyntaxKind.Parameter &&
declaration.initializer &&
getFalsyFlags(declaredType) & TypeFlags.Undefined &&
!(getFalsyFlags(checkExpression(declaration.initializer)) & TypeFlags.Undefined);
return annotationIncludesUndefined ? getTypeWithFacts(declaredType, TypeFacts.NEUndefined) : declaredType;
if (pushTypeResolution(declaration.symbol, TypeSystemPropertyName.DeclaredType)) {
const annotationIncludesUndefined = strictNullChecks &&
declaration.kind === SyntaxKind.Parameter &&
declaration.initializer &&
getFalsyFlags(declaredType) & TypeFlags.Undefined &&
!(getFalsyFlags(checkExpression(declaration.initializer)) & TypeFlags.Undefined);
popTypeResolution();
return annotationIncludesUndefined ? getTypeWithFacts(declaredType, TypeFacts.NEUndefined) : declaredType;
}
else {
reportCircularityError(declaration.symbol);
return declaredType;
}
}
function isConstraintPosition(node: Node) {
@@ -20947,7 +20958,7 @@ namespace ts {
break;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
if (hasModifier(container, ModifierFlags.Static)) {
if (hasModifier(container, ModifierFlags.Static) && !(compilerOptions.target === ScriptTarget.ESNext && compilerOptions.useDefineForClassFields)) {
error(node, Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
}
+62 -34
View File
@@ -1164,11 +1164,13 @@ namespace ts {
}
}
interface OptionsBase {
/*@internal*/
export interface OptionsBase {
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
}
interface ParseCommandLineWorkerDiagnostics extends DidYouMeanOptionsDiagnostics {
/*@internal*/
export interface ParseCommandLineWorkerDiagnostics extends DidYouMeanOptionsDiagnostics {
getOptionsNameMap: () => OptionsNameMap;
optionTypeMismatchDiagnostic: DiagnosticMessage;
}
@@ -1189,7 +1191,8 @@ namespace ts {
createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
}
function parseCommandLineWorker(
/*@internal*/
export function parseCommandLineWorker(
diagnostics: ParseCommandLineWorkerDiagnostics,
commandLine: readonly string[],
readFile?: (path: string) => string | undefined) {
@@ -1279,7 +1282,25 @@ namespace ts {
errors: Diagnostic[]
) {
if (opt.isTSConfigOnly) {
errors.push(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name));
const optValue = args[i];
if (optValue === "null") {
options[opt.name] = undefined;
i++;
}
else if (opt.type === "boolean") {
if (optValue === "false") {
options[opt.name] = false;
i++;
}
else {
if (optValue === "true") i++;
errors.push(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line, opt.name));
}
}
else {
errors.push(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line, opt.name));
if (optValue && !startsWith(optValue, "-")) i++;
}
}
else {
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
@@ -1287,42 +1308,49 @@ namespace ts {
errors.push(createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt)));
}
switch (opt.type) {
case "number":
options[opt.name] = parseInt(args[i]);
i++;
break;
case "boolean":
// boolean flag has optional value true, false, others
const optValue = args[i];
options[opt.name] = optValue !== "false";
// consume next argument as boolean flag value
if (optValue === "false" || optValue === "true") {
if (args[i] !== "null") {
switch (opt.type) {
case "number":
options[opt.name] = parseInt(args[i]);
i++;
}
break;
case "string":
options[opt.name] = args[i] || "";
i++;
break;
case "list":
const result = parseListTypeOption(opt, args[i], errors);
options[opt.name] = result || [];
if (result) {
break;
case "boolean":
// boolean flag has optional value true, false, others
const optValue = args[i];
options[opt.name] = optValue !== "false";
// consume next argument as boolean flag value
if (optValue === "false" || optValue === "true") {
i++;
}
break;
case "string":
options[opt.name] = args[i] || "";
i++;
}
break;
// If not a primitive, the possible types are specified in what is effectively a map of options.
default:
options[opt.name] = parseCustomTypeOption(<CommandLineOptionOfCustomType>opt, args[i], errors);
i++;
break;
break;
case "list":
const result = parseListTypeOption(opt, args[i], errors);
options[opt.name] = result || [];
if (result) {
i++;
}
break;
// If not a primitive, the possible types are specified in what is effectively a map of options.
default:
options[opt.name] = parseCustomTypeOption(<CommandLineOptionOfCustomType>opt, args[i], errors);
i++;
break;
}
}
else {
options[opt.name] = undefined;
i++;
}
}
return i;
}
const compilerOptionsDidYouMeanDiagnostics: ParseCommandLineWorkerDiagnostics = {
/*@internal*/
export const compilerOptionsDidYouMeanDiagnostics: ParseCommandLineWorkerDiagnostics = {
getOptionsNameMap,
optionDeclarations,
unknownOptionDiagnostic: Diagnostics.Unknown_compiler_option_0,
@@ -2170,7 +2198,7 @@ namespace ts {
}
function convertToOptionValueWithAbsolutePaths(option: CommandLineOption | undefined, value: CompilerOptionsValue, toAbsolutePath: (path: string) => string) {
if (option) {
if (option && !isNullOrUndefined(value)) {
if (option.type === "list") {
const values = value as readonly (string | number)[];
if (option.element.isFilePath && values.length) {
+5 -1
View File
@@ -3642,7 +3642,7 @@
"category": "Message",
"code": 6061
},
"Option '{0}' can only be specified in 'tsconfig.json' file.": {
"Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line.": {
"category": "Error",
"code": 6064
},
@@ -4296,6 +4296,10 @@
"category": "Error",
"code": 6229
},
"Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line.": {
"category": "Error",
"code": 6230
},
"Projects to reference": {
"category": "Message",
+1
View File
@@ -946,6 +946,7 @@ namespace ts {
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
getInstantiationCount: () => getDiagnosticsProducingTypeChecker().getInstantiationCount(),
getRelationCacheSizes: () => getDiagnosticsProducingTypeChecker().getRelationCacheSizes(),
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
+2 -3
View File
@@ -1180,7 +1180,6 @@ namespace ts {
let modifiers: NodeArray<Modifier> | undefined;
// If we're exporting these variables, then these just become assignments to 'exports.x'.
// We only want to emit assignments for variables with initializers.
for (const variable of node.declarationList.declarations) {
if (isIdentifier(variable.name) && isLocalName(variable.name)) {
if (!modifiers) {
@@ -1189,7 +1188,7 @@ namespace ts {
variables = append(variables, variable);
}
else if (variable.initializer) {
else {
expressions = append(expressions, transformInitializedVariable(variable));
}
}
@@ -1259,7 +1258,7 @@ namespace ts {
),
/*location*/ node.name
),
visitNode(node.initializer, moduleExpressionElementVisitor)
node.initializer ? visitNode(node.initializer, moduleExpressionElementVisitor) : createVoidZero()
);
}
}
+2
View File
@@ -3235,6 +3235,7 @@ namespace ts {
getIdentifierCount(): number;
getSymbolCount(): number;
getTypeCount(): number;
getInstantiationCount(): number;
getRelationCacheSizes(): { assignable: number, identity: number, subtype: number, strictSubtype: number };
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
@@ -3557,6 +3558,7 @@ namespace ts {
/* @internal */ getIdentifierCount(): number;
/* @internal */ getSymbolCount(): number;
/* @internal */ getTypeCount(): number;
/* @internal */ getInstantiationCount(): number;
/* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number, strictSubtype: number };
/* @internal */ isArrayType(type: Type): boolean;
@@ -639,6 +639,7 @@ namespace ts {
reportCountStatistic("Identifiers", program.getIdentifierCount());
reportCountStatistic("Symbols", program.getSymbolCount());
reportCountStatistic("Types", program.getTypeCount());
reportCountStatistic("Instantiations", program.getInstantiationCount());
if (memoryUsed >= 0) {
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
File diff suppressed because it is too large Load Diff
+2 -7
View File
@@ -2414,7 +2414,7 @@ namespace ts.server {
this.openFilesWithNonRootedDiskPath.set(this.toCanonicalFileName(fileName), info);
}
}
if (openedByClient && !info.isScriptOpen()) {
if (openedByClient) {
// Opening closed script info
// either it was created just now, or was part of projects but was closed
this.stopWatchingScriptInfo(info);
@@ -2423,9 +2423,6 @@ namespace ts.server {
info.registerFileUpdate();
}
}
else {
Debug.assert(fileContent === undefined);
}
return info;
}
@@ -3170,11 +3167,9 @@ namespace ts.server {
const iterResult = openFiles.next();
if (iterResult.done) break;
const file = iterResult.value;
const scriptInfo = this.getScriptInfo(file.fileName);
Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen(), "Script should not exist and not be open already");
// Create script infos so we have the new content for all the open files before we do any updates to projects
const info = this.getOrCreateOpenScriptInfo(
scriptInfo ? scriptInfo.fileName : toNormalizedPath(file.fileName),
toNormalizedPath(file.fileName),
file.content,
tryConvertScriptKindName(file.scriptKind!),
file.hasMixedContent,
+1
View File
@@ -126,6 +126,7 @@
"unittests/tsbuild/transitiveReferences.ts",
"unittests/tsbuild/watchEnvironment.ts",
"unittests/tsbuild/watchMode.ts",
"unittests/tsc/composite.ts",
"unittests/tsc/declarationEmit.ts",
"unittests/tsc/incremental.ts",
"unittests/tsc/listFilesOnly.ts",
@@ -1,11 +1,9 @@
namespace ts {
describe("unittests:: config:: commandLineParsing:: parseCommandLine", () => {
function assertParseResult(commandLine: string[], expectedParsedCommandLine: ParsedCommandLine) {
const parsed = parseCommandLine(commandLine);
const parsedCompilerOptions = JSON.stringify(parsed.options);
const expectedCompilerOptions = JSON.stringify(expectedParsedCommandLine.options);
assert.equal(parsedCompilerOptions, expectedCompilerOptions);
function assertParseResult(commandLine: string[], expectedParsedCommandLine: ParsedCommandLine, workerDiagnostic?: () => ParseCommandLineWorkerDiagnostics) {
const parsed = parseCommandLineWorker(workerDiagnostic?.() || compilerOptionsDidYouMeanDiagnostics, commandLine);
assert.deepEqual(parsed.options, expectedParsedCommandLine.options);
assert.deepEqual(parsed.watchOptions, expectedParsedCommandLine.watchOptions);
const parsedErrors = parsed.errors;
@@ -120,7 +118,7 @@ namespace ts {
length: undefined,
}],
fileNames: ["0.ts"],
options: {}
options: { jsx: undefined }
});
});
@@ -146,7 +144,7 @@ namespace ts {
length: undefined,
}],
fileNames: ["0.ts"],
options: {}
options: { module: undefined }
});
});
@@ -172,7 +170,7 @@ namespace ts {
length: undefined,
}],
fileNames: ["0.ts"],
options: {}
options: { newLine: undefined }
});
});
@@ -198,7 +196,7 @@ namespace ts {
length: undefined,
}],
fileNames: ["0.ts"],
options: {}
options: { target: undefined }
});
});
@@ -224,7 +222,7 @@ namespace ts {
length: undefined,
}],
fileNames: ["0.ts"],
options: {}
options: { moduleResolution: undefined }
});
});
@@ -414,6 +412,183 @@ namespace ts {
});
});
describe("parses command line null for tsconfig only option", () => {
interface VerifyNull {
optionName: string;
nonNullValue?: string;
workerDiagnostic?: () => ParseCommandLineWorkerDiagnostics;
diagnosticMessage: DiagnosticMessage;
}
function verifyNull({ optionName, nonNullValue, workerDiagnostic, diagnosticMessage }: VerifyNull) {
it("allows setting it to null", () => {
assertParseResult(
[`--${optionName}`, "null", "0.ts"],
{
errors: [],
fileNames: ["0.ts"],
options: { [optionName]: undefined }
},
workerDiagnostic
);
});
if (nonNullValue) {
it("errors if non null value is passed", () => {
assertParseResult(
[`--${optionName}`, nonNullValue, "0.ts"],
{
errors: [{
messageText: formatStringFromArgs(diagnosticMessage.message, [optionName]),
category: diagnosticMessage.category,
code: diagnosticMessage.code,
file: undefined,
start: undefined,
length: undefined
}],
fileNames: ["0.ts"],
options: {}
},
workerDiagnostic
);
});
}
it("errors if its followed by another option", () => {
assertParseResult(
["0.ts", "--strictNullChecks", `--${optionName}`],
{
errors: [{
messageText: formatStringFromArgs(diagnosticMessage.message, [optionName]),
category: diagnosticMessage.category,
code: diagnosticMessage.code,
file: undefined,
start: undefined,
length: undefined
}],
fileNames: ["0.ts"],
options: { strictNullChecks: true }
},
workerDiagnostic
);
});
it("errors if its last option", () => {
assertParseResult(
["0.ts", `--${optionName}`],
{
errors: [{
messageText: formatStringFromArgs(diagnosticMessage.message, [optionName]),
category: diagnosticMessage.category,
code: diagnosticMessage.code,
file: undefined,
start: undefined,
length: undefined
}],
fileNames: ["0.ts"],
options: {}
},
workerDiagnostic
);
});
}
interface VerifyNullNonIncludedOption {
type: () => "string" | "number" | Map<number | string>;
nonNullValue?: string;
}
function verifyNullNonIncludedOption({ type, nonNullValue }: VerifyNullNonIncludedOption) {
verifyNull({
optionName: "optionName",
nonNullValue,
diagnosticMessage: Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line,
workerDiagnostic: () => {
const optionDeclarations = [
...compilerOptionsDidYouMeanDiagnostics.optionDeclarations,
{
name: "optionName",
type: type(),
isTSConfigOnly: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Enable_project_compilation,
}
];
return {
...compilerOptionsDidYouMeanDiagnostics,
optionDeclarations,
getOptionsNameMap: () => createOptionNameMap(optionDeclarations)
};
}
});
}
describe("option of type boolean", () => {
it("allows setting it to false", () => {
assertParseResult(
["--composite", "false", "0.ts"],
{
errors: [],
fileNames: ["0.ts"],
options: { composite: false }
}
);
});
verifyNull({
optionName: "composite",
nonNullValue: "true",
diagnosticMessage: Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line
});
});
describe("option of type object", () => {
verifyNull({
optionName: "paths",
diagnosticMessage: Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line
});
});
describe("option of type list", () => {
verifyNull({
optionName: "rootDirs",
nonNullValue: "abc,xyz",
diagnosticMessage: Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line
});
});
describe("option of type string", () => {
verifyNullNonIncludedOption({
type: () => "string",
nonNullValue: "hello"
});
});
describe("option of type number", () => {
verifyNullNonIncludedOption({
type: () => "number",
nonNullValue: "10"
});
});
describe("option of type Map<number | string>", () => {
verifyNullNonIncludedOption({
type: () => createMapFromTemplate({
node: ModuleResolutionKind.NodeJs,
classic: ModuleResolutionKind.Classic,
}),
nonNullValue: "node"
});
});
});
it("allows tsconfig only option to be set to null", () => {
assertParseResult(["--composite", "null", "-tsBuildInfoFile", "null", "0.ts"],
{
errors: [],
fileNames: ["0.ts"],
options: { composite: undefined, tsBuildInfoFile: undefined }
});
});
describe("Watch options", () => {
it("parse --watchFile", () => {
assertParseResult(["--watchFile", "UseFsEvents", "0.ts"],
@@ -487,9 +662,7 @@ namespace ts {
describe("unittests:: config:: commandLineParsing:: parseBuildOptions", () => {
function assertParseResult(commandLine: string[], expectedParsedBuildCommand: ParsedBuildCommand) {
const parsed = parseBuildCommand(commandLine);
const parsedBuildOptions = JSON.stringify(parsed.buildOptions);
const expectedBuildOptions = JSON.stringify(expectedParsedBuildCommand.buildOptions);
assert.equal(parsedBuildOptions, expectedBuildOptions);
assert.deepEqual(parsed.buildOptions, expectedParsedBuildCommand.buildOptions);
assert.deepEqual(parsed.watchOptions, expectedParsedBuildCommand.watchOptions);
const parsedErrors = parsed.errors;
+85
View File
@@ -0,0 +1,85 @@
namespace ts {
describe("unittests:: tsc:: composite::", () => {
verifyTsc({
scenario: "composite",
subScenario: "when setting composite false on command line",
fs: () => loadProjectFromFiles({
"/src/project/src/main.ts": "export const x = 10;",
"/src/project/tsconfig.json": Utils.dedent`
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"composite": true,
},
"include": [
"src/**/*.ts"
]
}`,
}),
commandLineArgs: ["--composite", "false", "--p", "src/project"],
});
verifyTsc({
scenario: "composite",
subScenario: "when setting composite null on command line",
fs: () => loadProjectFromFiles({
"/src/project/src/main.ts": "export const x = 10;",
"/src/project/tsconfig.json": Utils.dedent`
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"composite": true,
},
"include": [
"src/**/*.ts"
]
}`,
}),
commandLineArgs: ["--composite", "null", "--p", "src/project"],
});
verifyTsc({
scenario: "composite",
subScenario: "when setting composite false on command line but has tsbuild info in config",
fs: () => loadProjectFromFiles({
"/src/project/src/main.ts": "export const x = 10;",
"/src/project/tsconfig.json": Utils.dedent`
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"composite": true,
"tsBuildInfoFile": "tsconfig.json.tsbuildinfo"
},
"include": [
"src/**/*.ts"
]
}`,
}),
commandLineArgs: ["--composite", "false", "--p", "src/project"],
});
verifyTsc({
scenario: "composite",
subScenario: "when setting composite false and tsbuildinfo as null on command line but has tsbuild info in config",
fs: () => loadProjectFromFiles({
"/src/project/src/main.ts": "export const x = 10;",
"/src/project/tsconfig.json": Utils.dedent`
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"composite": true,
"tsBuildInfoFile": "tsconfig.json.tsbuildinfo"
},
"include": [
"src/**/*.ts"
]
}`,
}),
commandLineArgs: ["--composite", "false", "--p", "src/project", "--tsBuildInfoFile", "null"],
});
});
}
@@ -29,7 +29,11 @@ ${file.content}`;
assert.equal(Number(project.getProjectVersion()), expected);
}
function verify(applyChangesToOpen: (session: TestSession) => void) {
interface Verify {
applyChangesToOpen: (session: TestSession) => void;
openFile1Again: (session: TestSession) => void;
}
function verify({ applyChangesToOpen, openFile1Again }: Verify) {
const host = createServerHost([app, file3, commonFile1, commonFile2, libFile, configFile]);
const session = createSession(host);
session.executeCommandSeq<protocol.OpenRequest>({
@@ -65,11 +69,22 @@ ${file.content}`;
verifyText(service, commonFile2.path, fileContentWithComment(commonFile2));
verifyText(service, app.path, "let zzz = 10;let zz = 10;let z = 1;");
verifyText(service, file3.path, file3.content);
// Open file1 again
openFile1Again(session);
assert.isTrue(service.getScriptInfo(commonFile1.path)!.isScriptOpen());
// Verify that file1 contents are changed
verifyProjectVersion(project, 4);
verifyText(service, commonFile1.path, commonFile1.content);
verifyText(service, commonFile2.path, fileContentWithComment(commonFile2));
verifyText(service, app.path, "let zzz = 10;let zz = 10;let z = 1;");
verifyText(service, file3.path, file3.content);
}
it("with applyChangedToOpenFiles request", () => {
verify(session =>
session.executeCommandSeq<protocol.ApplyChangedToOpenFilesRequest>({
verify({
applyChangesToOpen: session => session.executeCommandSeq<protocol.ApplyChangedToOpenFilesRequest>({
command: protocol.CommandTypes.ApplyChangedToOpenFiles,
arguments: {
openFiles: [
@@ -101,13 +116,22 @@ ${file.content}`;
file3.path
]
}
})
);
}),
openFile1Again: session => session.executeCommandSeq<protocol.ApplyChangedToOpenFilesRequest>({
command: protocol.CommandTypes.ApplyChangedToOpenFiles,
arguments: {
openFiles: [{
fileName: commonFile1.path,
content: commonFile1.content
}]
}
}),
});
});
it("with updateOpen request", () => {
verify(session =>
session.executeCommandSeq<protocol.UpdateOpenRequest>({
verify({
applyChangesToOpen: session => session.executeCommandSeq<protocol.UpdateOpenRequest>({
command: protocol.CommandTypes.UpdateOpen,
arguments: {
openFiles: [
@@ -141,8 +165,17 @@ ${file.content}`;
file3.path
]
}
})
);
}),
openFile1Again: session => session.executeCommandSeq<protocol.UpdateOpenRequest>({
command: protocol.CommandTypes.UpdateOpen,
arguments: {
openFiles: [{
file: commonFile1.path,
fileContent: commonFile1.content
}]
}
}),
});
});
});
}
@@ -104,5 +104,29 @@ namespace ts.projectSystem {
checkProjectActualFiles(project, files.map(f => f.path));
}
});
it("can open same file again", () => {
const projectFolder = "/user/someuser/projects/myproject";
const aFile: File = {
path: `${projectFolder}/src/a.ts`,
content: "export const x = 0;"
};
const configFile: File = {
path: `${projectFolder}/tsconfig.json`,
content: "{}"
};
const files = [aFile, configFile, libFile];
const host = createServerHost(files);
const service = createProjectService(host);
verifyProject(aFile.content);
verifyProject(`${aFile.content}export const y = 10;`);
function verifyProject(aFileContent: string) {
service.openClientFile(aFile.path, aFileContent, ScriptKind.TS, projectFolder);
const project = service.configuredProjects.get(configFile.path)!;
checkProjectActualFiles(project, files.map(f => f.path));
assert.equal(project.getCurrentProgram()?.getSourceFile(aFile.path)!.text, aFileContent);
}
});
});
}
@@ -21,6 +21,7 @@ export var a = function () {
//// [aliasUsedAsNameValue_0.js]
"use strict";
exports.__esModule = true;
exports.id = void 0;
//// [aliasUsedAsNameValue_1.js]
"use strict";
exports.__esModule = true;
+1
View File
@@ -1952,6 +1952,7 @@ declare namespace ts {
getIdentifierCount(): number;
getSymbolCount(): number;
getTypeCount(): number;
getInstantiationCount(): number;
getRelationCacheSizes(): {
assignable: number;
identity: number;
+1
View File
@@ -1952,6 +1952,7 @@ declare namespace ts {
getIdentifierCount(): number;
getSymbolCount(): number;
getTypeCount(): number;
getInstantiationCount(): number;
getRelationCacheSizes(): {
assignable: number;
identity: number;
@@ -0,0 +1,32 @@
tests/cases/compiler/circularOptionalityRemoval.ts(2,14): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
tests/cases/compiler/circularOptionalityRemoval.ts(2,38): error TS2372: Parameter 'x' cannot be referenced in its initializer.
tests/cases/compiler/circularOptionalityRemoval.ts(2,38): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/circularOptionalityRemoval.ts(2,46): error TS2372: Parameter 'x' cannot be referenced in its initializer.
tests/cases/compiler/circularOptionalityRemoval.ts(5,14): error TS1015: Parameter cannot have question mark and initializer.
tests/cases/compiler/circularOptionalityRemoval.ts(5,14): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
tests/cases/compiler/circularOptionalityRemoval.ts(5,27): error TS2304: Cannot find name 'someCondition'.
tests/cases/compiler/circularOptionalityRemoval.ts(5,54): error TS2372: Parameter 'x' cannot be referenced in its initializer.
==== tests/cases/compiler/circularOptionalityRemoval.ts (8 errors) ====
// Constructed repro
function fn1(x: number | undefined = x > 0 ? x : 0) { }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
~
!!! error TS2372: Parameter 'x' cannot be referenced in its initializer.
~
!!! error TS2532: Object is possibly 'undefined'.
~
!!! error TS2372: Parameter 'x' cannot be referenced in its initializer.
// Report from user
function fn2(x?: string = someCondition ? 'value1' : x) { }
~
!!! error TS1015: Parameter cannot have question mark and initializer.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'someCondition'.
~
!!! error TS2372: Parameter 'x' cannot be referenced in its initializer.
@@ -0,0 +1,16 @@
//// [circularOptionalityRemoval.ts]
// Constructed repro
function fn1(x: number | undefined = x > 0 ? x : 0) { }
// Report from user
function fn2(x?: string = someCondition ? 'value1' : x) { }
//// [circularOptionalityRemoval.js]
// Constructed repro
function fn1(x) {
if (x === void 0) { x = x > 0 ? x : 0; }
}
// Report from user
function fn2(x) {
if (x === void 0) { x = someCondition ? 'value1' : x; }
}
@@ -0,0 +1,14 @@
=== tests/cases/compiler/circularOptionalityRemoval.ts ===
// Constructed repro
function fn1(x: number | undefined = x > 0 ? x : 0) { }
>fn1 : Symbol(fn1, Decl(circularOptionalityRemoval.ts, 0, 0))
>x : Symbol(x, Decl(circularOptionalityRemoval.ts, 1, 13))
>x : Symbol(x, Decl(circularOptionalityRemoval.ts, 1, 13))
>x : Symbol(x, Decl(circularOptionalityRemoval.ts, 1, 13))
// Report from user
function fn2(x?: string = someCondition ? 'value1' : x) { }
>fn2 : Symbol(fn2, Decl(circularOptionalityRemoval.ts, 1, 55))
>x : Symbol(x, Decl(circularOptionalityRemoval.ts, 4, 13))
>x : Symbol(x, Decl(circularOptionalityRemoval.ts, 4, 13))
@@ -0,0 +1,21 @@
=== tests/cases/compiler/circularOptionalityRemoval.ts ===
// Constructed repro
function fn1(x: number | undefined = x > 0 ? x : 0) { }
>fn1 : (x?: number | undefined) => void
>x : number | undefined
>x > 0 ? x : 0 : number | undefined
>x > 0 : boolean
>x : number | undefined
>0 : 0
>x : number | undefined
>0 : 0
// Report from user
function fn2(x?: string = someCondition ? 'value1' : x) { }
>fn2 : (x?: string | undefined) => void
>x : string | undefined
>someCondition ? 'value1' : x : string | undefined
>someCondition : any
>'value1' : "value1"
>x : string | undefined
@@ -18,6 +18,7 @@ export class Test1 {
//// [classMemberInitializerWithLamdaScoping3_0.js]
"use strict";
exports.__esModule = true;
exports.field1 = void 0;
//// [classMemberInitializerWithLamdaScoping3_1.js]
"use strict";
exports.__esModule = true;
@@ -7,4 +7,6 @@ export var b: number;
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
/** b's comment*/
exports.b = void 0;
});
@@ -21,6 +21,7 @@ export var x: SubModule.m.m3.c;
//// [declFileAmbientExternalModuleWithSingleExportedModule_1.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
//// [declFileAmbientExternalModuleWithSingleExportedModule_0.d.ts]
@@ -20,6 +20,7 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.x = void 0;
exports.x.a;
});
@@ -61,6 +61,7 @@ define(["require", "exports", "declFileExportImportChain_b1"], function (require
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.x = void 0;
});
@@ -52,6 +52,7 @@ define(["require", "exports", "declFileExportImportChain2_b"], function (require
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.x = void 0;
});
@@ -14,6 +14,7 @@ var z = b.x;
//// [declFileForExportedImport_0.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
//// [declFileForExportedImport_1.js]
"use strict";
exports.__esModule = true;
@@ -89,6 +89,7 @@ var C;
}());
C.D = D;
})(C = exports.C || (exports.C = {}));
exports.a = void 0;
exports.b = C.F;
exports.c = C.F2;
exports.d = C.F3;
@@ -12,6 +12,7 @@ declare function dec<T>(target: T): T;
//// [decoratorOnImportEquals2_0.js]
"use strict";
exports.__esModule = true;
exports.X = void 0;
//// [decoratorOnImportEquals2_1.js]
"use strict";
exports.__esModule = true;
@@ -29,6 +29,7 @@ export { exportedFoo as foo, nonexportedFoo as nfoo };
"use strict";
var _a, _b, _c, _d, _e;
Object.defineProperty(exports, "__esModule", { value: true });
exports.exportedFoo = void 0;
exports.foo = exports.exportedFoo;
let nonexportedFoo;
exports.nonexportedFoo = nonexportedFoo;
@@ -6,5 +6,6 @@ import("./a");
//// [a.js]
"use strict";
exports.x = void 0;
Promise.resolve().then(function () { return require("./a"); });
module.exports = exports.x;
@@ -81,6 +81,7 @@ var c = { a: { x: 'hello', y: 2 } }; // error - y does not exist in type A
var d = { a: { x: 'hello' }, c: 5 }; // ok
var e = { a: { x: 2 }, c: 5 }; // error - types of property x are incompatible
var f = { a: { x: 'hello', y: 2 }, c: 5 }; // error - y does not exist in type A
exports.obj = void 0;
exports.photo = {
id: 1,
url: '',
@@ -40,11 +40,17 @@ define(["require", "exports"], function (require, exports) {
var ;
let;
var ;
exports.a = void 0;
exports.b = void 0;
exports.c = void 0;
exports.d = void 0;
var A = /** @class */ (function () {
function A() {
}
return A;
}());
exports.e = void 0;
exports.f = void 0;
var B;
(function (B) {
B.a = 1, B.c = 2;
@@ -39,11 +39,17 @@ exports.__esModule = true;
var ;
let;
var ;
exports.a = void 0;
exports.b = void 0;
exports.c = void 0;
exports.d = void 0;
var A = /** @class */ (function () {
function A() {
}
return A;
}());
exports.e = void 0;
exports.f = void 0;
var B;
(function (B) {
B.a = 1, B.c = 2;
@@ -48,11 +48,17 @@ export let h1: D = new D;
var ;
let;
var ;
exports.a = void 0;
exports.b = void 0;
exports.c = void 0;
exports.d = void 0;
var A = /** @class */ (function () {
function A() {
}
return A;
}());
exports.e = void 0;
exports.f = void 0;
var B;
(function (B) {
B.a = 1, B.c = 2;
@@ -16,4 +16,5 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.x = void 0;
});
+1
View File
@@ -901,6 +901,7 @@ define(["require", "exports"], function (require, exports) {
})(eM = M_1.eM || (M_1.eM = {}));
;
})(M || (M = {}));
exports.eV = void 0;
function eF() { }
exports.eF = eF;
;
+3
View File
@@ -90,6 +90,7 @@ var d = /** @class */ (function () {
return d;
}());
exports.d = d;
exports.x = void 0;
function foo() { return null; }
exports.foo = foo;
//// [importDecl_require1.js]
@@ -113,6 +114,7 @@ var d = /** @class */ (function () {
return d;
}());
exports.d = d;
exports.x = void 0;
function foo() { return null; }
exports.foo = foo;
//// [importDecl_require3.js]
@@ -124,6 +126,7 @@ var d = /** @class */ (function () {
return d;
}());
exports.d = d;
exports.x = void 0;
function foo() { return null; }
exports.foo = foo;
//// [importDecl_require4.js]
@@ -23,6 +23,7 @@ exports.B = B;
//// [importDeclarationUsedAsTypeQuery_1.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
//// [importDeclarationUsedAsTypeQuery_require.d.ts]
@@ -11,6 +11,7 @@ export var x: b;
//// [internalAliasInterfaceInsideTopLevelModuleWithExport.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
//// [internalAliasInterfaceInsideTopLevelModuleWithExport.d.ts]
@@ -12,6 +12,7 @@ export var x: b;
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.x = void 0;
});
@@ -24,4 +24,5 @@ define(["require", "exports"], function (require, exports) {
(function (c) {
c.x.foo();
})(c = exports.c || (exports.c = {}));
exports.z = void 0;
});
@@ -16,6 +16,7 @@ x.foo();
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.x = void 0;
exports.x.foo();
});
@@ -15,6 +15,7 @@ x.foo();
//// [internalAliasUninitializedModuleInsideTopLevelModuleWithoutExport.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
exports.x.foo();
@@ -4,3 +4,4 @@ export var x;
//// [file1.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
@@ -4,3 +4,4 @@ export var x;
//// [file1.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
@@ -18,6 +18,7 @@ fn(a); // Error: property 'x' is missing from 'a'
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.x = void 0;
});
//// [moduleAliasAsFunctionArgument_1.js]
define(["require", "exports", "moduleAliasAsFunctionArgument_0"], function (require, exports, a) {
@@ -15,6 +15,8 @@ var x = 1;
//// [a.js]
"use strict";
exports.__esModule = true;
/// <reference path="ref.ts"/>
exports.y = void 0;
//// [b.js]
"use strict";
exports.__esModule = true;
@@ -32,6 +32,7 @@ export let y: number;
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = void 0;
});
//// [file2.js]
define(["require", "exports", "module1", "templates/module2", "../file3"], function (require, exports, module1_1, module2_1, file3_1) {
@@ -31,6 +31,7 @@ export let y: number;
//// [module2.js]
"use strict";
exports.__esModule = true;
exports.b = void 0;
//// [file2.js]
"use strict";
exports.__esModule = true;
@@ -10,6 +10,7 @@ export var b = foo;
exports.__esModule = true;
function foo() {
}
exports.x = void 0;
exports.b = foo;
@@ -177,9 +177,11 @@ define(["require", "exports"], function (require, exports) {
var privateUse_im_public_v_private = exports.im_public_v_private;
exports.publicUse_im_public_v_private = exports.im_public_v_private;
var privateUse_im_public_i_private;
exports.publicUse_im_public_i_private = void 0;
var privateUse_im_public_mi_private = new exports.im_public_mi_private.c();
exports.publicUse_im_public_mi_private = new exports.im_public_mi_private.c();
var privateUse_im_public_mu_private;
exports.publicUse_im_public_mu_private = void 0;
// No Privacy errors - importing public elements
exports.im_public_c_public = m_public.c_public;
exports.im_public_e_public = m_public.e_public;
@@ -196,9 +198,11 @@ define(["require", "exports"], function (require, exports) {
var privateUse_im_public_v_public = exports.im_public_v_public;
exports.publicUse_im_public_v_public = exports.im_public_v_public;
var privateUse_im_public_i_public;
exports.publicUse_im_public_i_public = void 0;
var privateUse_im_public_mi_public = new exports.im_public_mi_public.c();
exports.publicUse_im_public_mi_public = new exports.im_public_mi_public.c();
var privateUse_im_public_mu_public;
exports.publicUse_im_public_mu_public = void 0;
});
@@ -177,9 +177,11 @@ define(["require", "exports"], function (require, exports) {
var privateUse_im_private_v_private = im_private_v_private;
exports.publicUse_im_private_v_private = im_private_v_private;
var privateUse_im_private_i_private;
exports.publicUse_im_private_i_private = void 0;
var privateUse_im_private_mi_private = new im_private_mi_private.c();
exports.publicUse_im_private_mi_private = new im_private_mi_private.c();
var privateUse_im_private_mu_private;
exports.publicUse_im_private_mu_private = void 0;
// No Privacy errors - importing public elements
var im_private_c_public = m_public.c_public;
var im_private_e_public = m_public.e_public;
@@ -196,9 +198,11 @@ define(["require", "exports"], function (require, exports) {
var privateUse_im_private_v_public = im_private_v_public;
exports.publicUse_im_private_v_public = im_private_v_public;
var privateUse_im_private_i_public;
exports.publicUse_im_private_i_public = void 0;
var privateUse_im_private_mi_public = new im_private_mi_public.c();
exports.publicUse_im_private_mi_public = new im_private_mi_public.c();
var privateUse_im_private_mu_public;
exports.publicUse_im_private_mu_public = void 0;
});
+2
View File
@@ -324,7 +324,9 @@ var glo_C4_public = /** @class */ (function () {
return glo_C4_public;
}());
var glo_v1_private;
exports.glo_v2_public = void 0;
var glo_v3_private;
exports.glo_v4_public = void 0; // error
var glo_v11_private = new glo_C1_public();
exports.glo_v12_public = new glo_C1_public();
var glo_v13_private = new glo_C2_private();
@@ -460,6 +460,8 @@ var privateClassWithWithPublicPropertyTypes = /** @class */ (function () {
}
return privateClassWithWithPublicPropertyTypes;
}());
exports.publicVarWithPrivatePropertyTypes = void 0; // Error
exports.publicVarWithPublicPropertyTypes = void 0;
var privateVarWithPrivatePropertyTypes;
var privateVarWithPublicPropertyTypes;
var publicClassWithPrivateModulePropertyTypes = /** @class */ (function () {
@@ -468,6 +470,7 @@ var publicClassWithPrivateModulePropertyTypes = /** @class */ (function () {
return publicClassWithPrivateModulePropertyTypes;
}());
exports.publicClassWithPrivateModulePropertyTypes = publicClassWithPrivateModulePropertyTypes;
exports.publicVarWithPrivateModulePropertyTypes = void 0; // Error
var privateClassWithPrivateModulePropertyTypes = /** @class */ (function () {
function privateClassWithPrivateModulePropertyTypes() {
}
@@ -8,6 +8,7 @@ define(["require", "exports"], function (require, exports) {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -7,6 +7,7 @@ var d = /** @class */ (function () {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -8,6 +8,7 @@ define(["require", "exports"], function (require, exports) {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -7,6 +7,7 @@ var d = /** @class */ (function () {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -8,6 +8,7 @@ define(["require", "exports"], function (require, exports) {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -7,6 +7,7 @@ var d = /** @class */ (function () {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -8,6 +8,7 @@ define(["require", "exports"], function (require, exports) {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -7,6 +7,7 @@ var d = /** @class */ (function () {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -8,6 +8,7 @@ define(["require", "exports"], function (require, exports) {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -7,6 +7,7 @@ var d = /** @class */ (function () {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -8,6 +8,7 @@ define(["require", "exports"], function (require, exports) {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -7,6 +7,7 @@ var d = /** @class */ (function () {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -8,6 +8,7 @@ define(["require", "exports"], function (require, exports) {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -7,6 +7,7 @@ var d = /** @class */ (function () {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -8,6 +8,7 @@ define(["require", "exports"], function (require, exports) {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -7,6 +7,7 @@ var d = /** @class */ (function () {
}());
exports.d = d;
;
exports.x = void 0;
function foo() {
return new d();
}
@@ -22,6 +22,7 @@ class C {
//// [protoAsIndexInIndexExpression_0.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
//// [protoAsIndexInIndexExpression_1.js]
///<reference path='protoAsIndexInIndexExpression_0.ts'/>
var EntityPrototype = undefined;
@@ -30,4 +30,5 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = void 0; // This should result in type ClassB
});
@@ -34,4 +34,5 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = void 0; // This should result in type ClassB
});
@@ -38,4 +38,5 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = void 0; // This should result in type ClassB
});
@@ -32,4 +32,5 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = void 0; // This should result in type ClassB
});
@@ -41,4 +41,5 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = void 0; // This should result in type ClassB
});
@@ -50,4 +50,5 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = void 0; // This should result in type ClassB
});
@@ -52,4 +52,5 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = void 0; // This should result in type ClassB
});
@@ -21,6 +21,8 @@ b = {
"use strict";
exports.__esModule = true;
exports.a.___foo;
// @filename def.ts
exports.b = void 0;
exports.b = {
___foo: 100
};
@@ -0,0 +1,23 @@
//// [thisInClassBodyStaticESNext.ts]
// all are allowed with es-compliant class field emit
class Foo {
x = this
static t = this
static at = () => this
static ft = function () { return this }
static mt() { return this }
}
//// [thisInClassBodyStaticESNext.js]
// all are allowed with es-compliant class field emit
const Foo = /** @class */ (() => {
class Foo {
x = this;
static t = this;
static at = () => this;
static ft = function () { return this; };
static mt() { return this; }
}
return Foo;
})();
@@ -0,0 +1,25 @@
=== tests/cases/compiler/thisInClassBodyStaticESNext.ts ===
// all are allowed with es-compliant class field emit
class Foo {
>Foo : Symbol(Foo, Decl(thisInClassBodyStaticESNext.ts, 0, 0))
x = this
>x : Symbol(Foo.x, Decl(thisInClassBodyStaticESNext.ts, 1, 11))
>this : Symbol(Foo, Decl(thisInClassBodyStaticESNext.ts, 0, 0))
static t = this
>t : Symbol(Foo.t, Decl(thisInClassBodyStaticESNext.ts, 2, 12))
>this : Symbol(Foo, Decl(thisInClassBodyStaticESNext.ts, 0, 0))
static at = () => this
>at : Symbol(Foo.at, Decl(thisInClassBodyStaticESNext.ts, 3, 19))
>this : Symbol(Foo, Decl(thisInClassBodyStaticESNext.ts, 0, 0))
static ft = function () { return this }
>ft : Symbol(Foo.ft, Decl(thisInClassBodyStaticESNext.ts, 4, 26))
static mt() { return this }
>mt : Symbol(Foo.mt, Decl(thisInClassBodyStaticESNext.ts, 5, 43))
>this : Symbol(Foo, Decl(thisInClassBodyStaticESNext.ts, 0, 0))
}
@@ -0,0 +1,28 @@
=== tests/cases/compiler/thisInClassBodyStaticESNext.ts ===
// all are allowed with es-compliant class field emit
class Foo {
>Foo : Foo
x = this
>x : this
>this : this
static t = this
>t : typeof Foo
>this : typeof Foo
static at = () => this
>at : () => typeof Foo
>() => this : () => typeof Foo
>this : typeof Foo
static ft = function () { return this }
>ft : () => any
>function () { return this } : () => any
>this : any
static mt() { return this }
>mt : () => typeof Foo
>this : typeof Foo
}
@@ -15,6 +15,7 @@ var z = foo.x + fum.y;
//// [foo_0.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
//// [foo_1.js]
"use strict";
exports.__esModule = true;
@@ -0,0 +1,11 @@
//// [/lib/initial-buildOutput.txt]
/lib/tsc --composite false --p src/project --tsBuildInfoFile null
exitCode:: ExitStatus.Success
//// [/src/project/src/main.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.x = 10;
@@ -0,0 +1,12 @@
//// [/lib/initial-buildOutput.txt]
/lib/tsc --composite false --p src/project
src/project/tsconfig.json(6,9): error TS5069: Option 'tsBuildInfoFile' cannot be specified without specifying option 'incremental' or option 'composite'.
exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated
//// [/src/project/src/main.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.x = 10;
@@ -0,0 +1,11 @@
//// [/lib/initial-buildOutput.txt]
/lib/tsc --composite false --p src/project
exitCode:: ExitStatus.Success
//// [/src/project/src/main.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.x = 10;
@@ -0,0 +1,11 @@
//// [/lib/initial-buildOutput.txt]
/lib/tsc --composite null --p src/project
exitCode:: ExitStatus.Success
//// [/src/project/src/main.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.x = 10;
@@ -120,7 +120,15 @@ Change:: Change the content of moduleFile1 to `export var T: number;export funct
//// [/a/b/moduleFile1.ts]
export var T: number;export function Foo() { };
//// [/a/b/moduleFile1.js] file written with same contents
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { }
exports.Foo = Foo;
;
Output::
>> Screen clear
@@ -118,7 +118,15 @@ Change:: change moduleFile1 shape and delete file1Consumer2
//// [/a/b/moduleFile1.ts]
export var T: number;export function Foo() { };
//// [/a/b/moduleFile1.js] file written with same contents
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { }
exports.Foo = Foo;
;
//// [/a/b/file1Consumer1.js] file written with same contents
//// [/a/b/file1Consumer2.ts] deleted
@@ -118,7 +118,15 @@ Change:: change moduleFile1 shape and create file1Consumer3
//// [/a/b/moduleFile1.ts]
export var T: number;export function Foo() { };
//// [/a/b/moduleFile1.js] file written with same contents
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { }
exports.Foo = Foo;
;
//// [/a/b/file1Consumer1.js] file written with same contents
//// [/a/b/file1Consumer2.js] file written with same contents
//// [/a/b/file1Consumer3.ts]
@@ -180,7 +180,15 @@ Change:: Change the content of moduleFile1 to `export var T: number;export funct
//// [/a/b/moduleFile1.ts]
export var T: number;export function Foo() { };
//// [/a/b/moduleFile1.js] file written with same contents
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { }
exports.Foo = Foo;
;
//// [/a/b/file1Consumer2.js] file written with same contents
Output::
@@ -374,6 +382,7 @@ export var T: number;export function Foo() { };
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { }
exports.Foo = Foo;
;
@@ -118,7 +118,15 @@ Change:: Change the content of moduleFile1 to `export var T: number;export funct
//// [/a/b/moduleFile1.ts]
export var T: number;export function Foo() { };
//// [/a/b/moduleFile1.js] file written with same contents
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { }
exports.Foo = Foo;
;
//// [/a/b/file1Consumer1.js] file written with same contents
//// [/a/b/file1Consumer2.js] file written with same contents
@@ -180,6 +188,7 @@ export var T: number;export function Foo() { console.log('hi'); };
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { console.log('hi'); }
exports.Foo = Foo;
;
@@ -89,7 +89,15 @@ Change:: Change the content of moduleFile1 to `export var T: number;export funct
//// [/a/b/moduleFile1.ts]
export var T: number;export function Foo() { };
//// [/a/b/moduleFile1.js] file written with same contents
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { }
exports.Foo = Foo;
;
//// [/a/b/file1Consumer1.js] file written with same contents
Output::
@@ -138,6 +146,7 @@ export var T: number;export function Foo() { };var T1: number;
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { }
exports.Foo = Foo;
;
@@ -130,7 +130,13 @@ Change:: change file1Consumer1
//// [/a/b/file1Consumer1.ts]
import {Foo} from "./moduleFile1"; export var y = 10;export var T: number;
//// [/a/b/file1Consumer1.js] file written with same contents
//// [/a/b/file1Consumer1.js]
"use strict";
exports.__esModule = true;
exports.y = 10;
exports.T = void 0;
//// [/a/b/file1Consumer1Consumer1.js] file written with same contents
Output::
@@ -190,7 +196,15 @@ Change:: Change the content of moduleFile1 to `export var T: number;export funct
//// [/a/b/moduleFile1.ts]
export var T: number;export function Foo() { };
//// [/a/b/moduleFile1.js] file written with same contents
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T = void 0;
function Foo() { }
exports.Foo = Foo;
;
//// [/a/b/file1Consumer1.js] file written with same contents
//// [/a/b/file1Consumer2.js] file written with same contents
@@ -255,8 +269,23 @@ export var T2: number;export function Foo() { };
//// [/a/b/file1Consumer1.ts]
import {Foo} from "./moduleFile1"; export var y = 10;export var T: number;export var T2: number;
//// [/a/b/moduleFile1.js] file written with same contents
//// [/a/b/file1Consumer1.js] file written with same contents
//// [/a/b/moduleFile1.js]
"use strict";
exports.__esModule = true;
exports.T2 = void 0;
function Foo() { }
exports.Foo = Foo;
;
//// [/a/b/file1Consumer1.js]
"use strict";
exports.__esModule = true;
exports.y = 10;
exports.T = void 0;
exports.T2 = void 0;
//// [/a/b/file1Consumer1Consumer1.js] file written with same contents
//// [/a/b/file1Consumer2.js] file written with same contents
@@ -39,6 +39,7 @@ else {
}
// exported variable in external module
var strOrNum;
exports.var2 = void 0;
if (typeof exports.var2 === "string") {
// export makes the var property and not variable
strOrNum = exports.var2; // string | number
@@ -19,6 +19,7 @@ export let y = () => x
/// <reference types="lib"/>
exports.__esModule = true;
exports.$ = 1;
exports.x = void 0;
exports.y = function () { return exports.x; };
@@ -55,14 +55,23 @@ export var r13: typeof foo;
"use strict";
exports.__esModule = true;
var x = 1;
exports.r1 = void 0;
var y = { foo: '' };
exports.r2 = void 0;
var C = /** @class */ (function () {
function C() {
}
return C;
}());
exports.c = void 0;
var c2;
exports.r3 = void 0;
exports.r4 = void 0;
exports.r4b = void 0;
exports.i = void 0;
var i2;
exports.r5 = void 0;
exports.r5 = void 0;
var M;
(function (M) {
M.foo = '';
@@ -73,10 +82,17 @@ var M;
}());
M.C = C;
})(M || (M = {}));
exports.r6 = void 0;
exports.r7 = void 0;
exports.r8 = void 0;
exports.r9 = void 0;
var E;
(function (E) {
E[E["A"] = 0] = "A";
})(E || (E = {}));
exports.r10 = void 0;
exports.r11 = void 0;
exports.r12 = void 0;
function foo() { }
(function (foo) {
foo.y = 1;
@@ -87,3 +103,4 @@ function foo() { }
}());
foo.C = C;
})(foo || (foo = {}));
exports.r13 = void 0;
@@ -55,15 +55,24 @@ export var r13: typeof foo;
"use strict";
exports.__esModule = true;
exports.x = 1;
exports.r1 = void 0;
exports.y = { foo: '' };
exports.r2 = void 0;
var C = /** @class */ (function () {
function C() {
}
return C;
}());
exports.C = C;
exports.c = void 0;
var c2;
exports.r3 = void 0;
exports.r4 = void 0;
exports.r4b = void 0;
exports.i = void 0;
var i2;
exports.r5 = void 0;
exports.r5 = void 0;
var M;
(function (M) {
M.foo = '';
@@ -74,11 +83,18 @@ var M;
}());
M.C = C;
})(M = exports.M || (exports.M = {}));
exports.r6 = void 0;
exports.r7 = void 0;
exports.Z = M;
exports.r8 = void 0;
exports.r9 = void 0;
var E;
(function (E) {
E[E["A"] = 0] = "A";
})(E = exports.E || (exports.E = {}));
exports.r10 = void 0;
exports.r11 = void 0;
exports.r12 = void 0;
function foo() { }
exports.foo = foo;
(function (foo) {
@@ -90,3 +106,4 @@ exports.foo = foo;
}());
foo.C = C;
})(foo = exports.foo || (exports.foo = {}));
exports.r13 = void 0;

Some files were not shown because too many files have changed in this diff Show More