+`,
+ },
+ {
+ path: "/@emotion/core/index.d.ts",
+ content: `import { createElement } from 'react'
+export const jsx: typeof createElement;
+export function Global(props: any): ReactElement;`
+ },
+ {
+ path: reactLibFile.path,
+ content: `${reactLibFile.content}
+export namespace React {
+ interface FunctionComponent {
+ }
+}
+`
+ }
+ );
+
describe("Exports", () => {
testOrganizeExports("MoveToTop",
diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts
index 72da8dbf85e..c1ddb0aa4e7 100644
--- a/src/testRunner/unittests/tsbuildWatchMode.ts
+++ b/src/testRunner/unittests/tsbuildWatchMode.ts
@@ -479,7 +479,7 @@ let x: string = 10;`);
const { host, solutionBuilder } = createSolutionOfProject(allFiles, currentDirectory, solutionBuilderconfig, getOutputFileStamps);
// Build in watch mode
- const watch = createWatchOfConfigFileReturningBuilder(watchConfig, host);
+ const watch = createWatchOfConfigFile(watchConfig, host);
checkOutputErrorsInitial(host, emptyArray);
return { host, solutionBuilder, watch };
@@ -505,10 +505,8 @@ let x: string = 10;`);
projectSystem.checkProjectActualFiles(service.configuredProjects.get(configFile.toLowerCase())!, expectedFiles);
}
- type Watch = () => BuilderProgram;
-
function verifyDependencies(watch: Watch, filePath: string, expected: ReadonlyArray) {
- checkArray(`${filePath} dependencies`, watch().getAllDependencies(watch().getSourceFile(filePath)!), expected);
+ checkArray(`${filePath} dependencies`, watch.getBuilderProgram().getAllDependencies(watch().getSourceFile(filePath)!), expected);
}
describe("on sample project", () => {
@@ -542,7 +540,7 @@ let x: string = 10;`);
host.checkTimeoutQueueLengthAndRun(1);
checkOutputErrorsIncremental(host, emptyArray);
- checkProgramActualFiles(watch().getProgram(), expectedFilesAfterEdit);
+ checkProgramActualFiles(watch(), expectedFilesAfterEdit);
});
@@ -642,7 +640,7 @@ export function gfoo() {
expectedWatchedDirectoriesRecursive: ReadonlyArray,
dependencies: ReadonlyArray<[string, ReadonlyArray]>,
expectedWatchedDirectories?: ReadonlyArray) {
- checkProgramActualFiles(watch().getProgram(), expectedProgramFiles);
+ checkProgramActualFiles(watch(), expectedProgramFiles);
verifyWatchesOfProject(host, expectedWatchedFiles, expectedWatchedDirectoriesRecursive, expectedWatchedDirectories);
for (const [file, deps] of dependencies) {
verifyDependencies(watch, file, deps);
diff --git a/src/testRunner/unittests/tscWatch/emitAndErrorUpdates.ts b/src/testRunner/unittests/tscWatch/emitAndErrorUpdates.ts
new file mode 100644
index 00000000000..b76c9a985d4
--- /dev/null
+++ b/src/testRunner/unittests/tscWatch/emitAndErrorUpdates.ts
@@ -0,0 +1,307 @@
+namespace ts.tscWatch {
+ describe("unittests:: tsc-watch:: Emit times and Error updates in builder after program changes", () => {
+ const currentDirectory = "/user/username/projects/myproject";
+ const config: File = {
+ path: `${currentDirectory}/tsconfig.json`,
+ content: `{}`
+ };
+ function getOutputFileStampAndError(host: WatchedSystem, watch: Watch, file: File) {
+ const builderProgram = watch.getBuilderProgram();
+ const state = builderProgram.getState();
+ return {
+ 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)
+ };
+ }
+
+ function getOutputFileStampsAndErrors(host: WatchedSystem, watch: Watch, directoryFiles: ReadonlyArray) {
+ return directoryFiles.map(d => getOutputFileStampAndError(host, watch, d));
+ }
+
+ function findStampAndErrors(stampsAndErrors: ReadonlyArray>, file: File) {
+ return find(stampsAndErrors, info => info.file === file)!;
+ }
+
+ function verifyOutputFileStampsAndErrors(
+ file: File,
+ emitExpected: boolean,
+ errorRefershExpected: boolean,
+ beforeChangeFileStampsAndErrors: ReadonlyArray>,
+ afterChangeFileStampsAndErrors: ReadonlyArray>
+ ) {
+ const beforeChange = findStampAndErrors(beforeChangeFileStampsAndErrors, file);
+ const afterChange = findStampAndErrors(afterChangeFileStampsAndErrors, file);
+ if (emitExpected) {
+ 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 (errorRefershExpected) {
+ if (afterChange.errors !== emptyArray || beforeChange.errors !== emptyArray) {
+ assert.notStrictEqual(afterChange.errors, beforeChange.errors, `Expected new errors for file ${file.path}`);
+ }
+ assert.isFalse(afterChange.errorsFromOldState, `Expected errors to be not copied from old state for file ${file.path}`);
+ }
+ else {
+ assert.strictEqual(afterChange.errors, beforeChange.errors, `Expected errors to not change for file ${file.path}`);
+ assert.isTrue(afterChange.errorsFromOldState, `Expected errors to be copied from old state for file ${file.path}`);
+ }
+ }
+
+ interface VerifyEmitAndErrorUpdates {
+ change: (host: WatchedSystem) => void;
+ getInitialErrors: (watch: Watch) => ReadonlyArray | ReadonlyArray;
+ getIncrementalErrors: (watch: Watch) => ReadonlyArray | ReadonlyArray;
+ filesWithNewEmit: ReadonlyArray;
+ filesWithOnlyErrorRefresh: ReadonlyArray;
+ filesNotTouched: ReadonlyArray;
+ configFile?: File;
+ }
+
+ function verifyEmitAndErrorUpdates({ filesWithNewEmit, filesWithOnlyErrorRefresh, filesNotTouched, configFile = config, change, getInitialErrors, getIncrementalErrors }: VerifyEmitAndErrorUpdates) {
+ const nonLibFiles = [...filesWithNewEmit, ...filesWithOnlyErrorRefresh, ...filesNotTouched];
+ const files = [...nonLibFiles, configFile, libFile];
+ const host = createWatchedSystem(files, { currentDirectory });
+ const watch = createWatchOfConfigFile("tsconfig.json", host);
+ checkProgramActualFiles(watch(), [...nonLibFiles.map(f => f.path), libFile.path]);
+ checkOutputErrorsInitial(host, getInitialErrors(watch));
+ const beforeChange = getOutputFileStampsAndErrors(host, watch, nonLibFiles);
+ change(host);
+ 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));
+ }
+
+ describe("deep import changes", () => {
+ const aFile: File = {
+ path: `${currentDirectory}/a.ts`,
+ content: `import {B} from './b';
+declare var console: any;
+let b = new B();
+console.log(b.c.d);`
+ };
+
+ function verifyDeepImportChange(bFile: File, cFile: File) {
+ const filesWithNewEmit: File[] = [];
+ const filesWithOnlyErrorRefresh = [aFile];
+ addImportedModule(bFile);
+ addImportedModule(cFile);
+ verifyEmitAndErrorUpdates({
+ filesWithNewEmit,
+ filesWithOnlyErrorRefresh,
+ filesNotTouched: emptyArray,
+ change: host => host.writeFile(cFile.path, cFile.content.replace("d", "d2")),
+ getInitialErrors: () => emptyArray,
+ getIncrementalErrors: watch => [
+ getDiagnosticOfFileFromProgram(watch(), aFile.path, aFile.content.lastIndexOf("d"), 1, Diagnostics.Property_0_does_not_exist_on_type_1, "d", "C")
+ ]
+ });
+
+ function addImportedModule(file: File) {
+ if (file.path.endsWith(".d.ts")) {
+ filesWithOnlyErrorRefresh.push(file);
+ }
+ else {
+ filesWithNewEmit.push(file);
+ }
+ }
+ }
+
+ it("updates errors when deep import file changes", () => {
+ const bFile: File = {
+ path: `${currentDirectory}/b.ts`,
+ content: `import {C} from './c';
+export class B
+{
+ c = new C();
+}`
+ };
+ const cFile: File = {
+ path: `${currentDirectory}/c.ts`,
+ content: `export class C
+{
+ d = 1;
+}`
+ };
+ verifyDeepImportChange(bFile, cFile);
+ });
+
+ it("updates errors when deep import through declaration file changes", () => {
+ const bFile: File = {
+ path: `${currentDirectory}/b.d.ts`,
+ content: `import {C} from './c';
+export class B
+{
+ c: C;
+}`
+ };
+ const cFile: File = {
+ path: `${currentDirectory}/c.d.ts`,
+ content: `export class C
+{
+ d: number;
+}`
+ };
+ verifyDeepImportChange(bFile, cFile);
+ });
+ });
+
+ it("updates errors in file not exporting a deep multilevel import that changes", () => {
+ const aFile: File = {
+ path: `${currentDirectory}/a.ts`,
+ content: `export interface Point {
+ name: string;
+ c: Coords;
+}
+export interface Coords {
+ x2: number;
+ y: number;
+}`
+ };
+ const bFile: File = {
+ path: `${currentDirectory}/b.ts`,
+ content: `import { Point } from "./a";
+export interface PointWrapper extends Point {
+}`
+ };
+ const cFile: File = {
+ path: `${currentDirectory}/c.ts`,
+ content: `import { PointWrapper } from "./b";
+export function getPoint(): PointWrapper {
+ return {
+ name: "test",
+ c: {
+ x: 1,
+ y: 2
+ }
+ }
+};`
+ };
+ const dFile: File = {
+ path: `${currentDirectory}/d.ts`,
+ content: `import { getPoint } from "./c";
+getPoint().c.x;`
+ };
+ const eFile: File = {
+ path: `${currentDirectory}/e.ts`,
+ content: `import "./d";`
+ };
+ verifyEmitAndErrorUpdates({
+ filesWithNewEmit: [aFile, bFile],
+ filesWithOnlyErrorRefresh: [cFile, dFile],
+ filesNotTouched: [eFile],
+ change: host => host.writeFile(aFile.path, aFile.content.replace("x2", "x")),
+ getInitialErrors: watch => [
+ getDiagnosticOfFileFromProgram(watch(), cFile.path, cFile.content.indexOf("x: 1"), 4, chainDiagnosticMessages(
+ chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, "x", "Coords"),
+ Diagnostics.Type_0_is_not_assignable_to_type_1,
+ "{ x: number; y: number; }",
+ "Coords"
+ )),
+ getDiagnosticOfFileFromProgram(watch(), dFile.path, dFile.content.lastIndexOf("x"), 1, Diagnostics.Property_0_does_not_exist_on_type_1, "x", "Coords")
+ ],
+ getIncrementalErrors: () => emptyArray
+ });
+ });
+
+ describe("updates errors when file transitively exported file changes", () => {
+ const config: File = {
+ path: `${currentDirectory}/tsconfig.json`,
+ content: JSON.stringify({
+ files: ["app.ts"],
+ compilerOptions: { baseUrl: "." }
+ })
+ };
+ const app: File = {
+ path: `${currentDirectory}/app.ts`,
+ content: `import { Data } from "lib2/public";
+export class App {
+ public constructor() {
+ new Data().test();
+ }
+}`
+ };
+ const lib2Public: File = {
+ path: `${currentDirectory}/lib2/public.ts`,
+ content: `export * from "./data";`
+ };
+ const lib2Data: File = {
+ path: `${currentDirectory}/lib2/data.ts`,
+ content: `import { ITest } from "lib1/public";
+export class Data {
+ public test() {
+ const result: ITest = {
+ title: "title"
+ }
+ return result;
+ }
+}`
+ };
+ const lib1Public: File = {
+ path: `${currentDirectory}/lib1/public.ts`,
+ content: `export * from "./tools/public";`
+ };
+ const lib1ToolsPublic: File = {
+ path: `${currentDirectory}/lib1/tools/public.ts`,
+ content: `export * from "./tools.interface";`
+ };
+ const lib1ToolsInterface: File = {
+ path: `${currentDirectory}/lib1/tools/tools.interface.ts`,
+ content: `export interface ITest {
+ title: string;
+}`
+ };
+
+ function verifyTransitiveExports(lib2Data: File, lib2Data2?: File) {
+ const filesWithNewEmit = [lib1ToolsInterface, lib1ToolsPublic];
+ const filesWithOnlyErrorRefresh = [app, lib2Public, lib1Public, lib2Data];
+ if (lib2Data2) {
+ filesWithOnlyErrorRefresh.push(lib2Data2);
+ }
+ verifyEmitAndErrorUpdates({
+ filesWithNewEmit,
+ filesWithOnlyErrorRefresh,
+ filesNotTouched: emptyArray,
+ configFile: config,
+ change: host => host.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title", "title2")),
+ getInitialErrors: () => emptyArray,
+ getIncrementalErrors: () => [
+ "lib2/data.ts(5,13): error TS2322: Type '{ title: string; }' is not assignable to type 'ITest'.\n Object literal may only specify known properties, but 'title' does not exist in type 'ITest'. Did you mean to write 'title2'?\n"
+ ]
+ });
+ }
+ it("when there are no circular import and exports", () => {
+ verifyTransitiveExports(lib2Data);
+ });
+
+ it("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";
+export class Data {
+ public dat?: Data2; public test() {
+ const result: ITest = {
+ title: "title"
+ }
+ return result;
+ }
+}`
+ };
+ const lib2Data2: File = {
+ path: `${currentDirectory}/lib2/data2.ts`,
+ content: `import { Data } from "./data";
+export class Data2 {
+ public dat?: Data;
+}`
+ };
+ verifyTransitiveExports(lib2Data, lib2Data2);
+ });
+ });
+ });
+}
diff --git a/src/testRunner/unittests/tscWatch/helpers.ts b/src/testRunner/unittests/tscWatch/helpers.ts
index af896009c0d..b593cabbec6 100644
--- a/src/testRunner/unittests/tscWatch/helpers.ts
+++ b/src/testRunner/unittests/tscWatch/helpers.ts
@@ -29,18 +29,18 @@ namespace ts.tscWatch {
checkArray(`Program rootFileNames`, program.getRootFileNames(), expectedFiles);
}
- export function createWatchOfConfigFileReturningBuilder(configFileName: string, host: WatchedSystem, maxNumberOfFilesToIterateForInvalidation?: number) {
- const compilerHost = createWatchCompilerHostOfConfigFile(configFileName, {}, host);
- compilerHost.maxNumberOfFilesToIterateForInvalidation = maxNumberOfFilesToIterateForInvalidation;
- const watch = createWatchProgram(compilerHost);
- return () => watch.getCurrentProgram();
+ export interface Watch {
+ (): Program;
+ getBuilderProgram(): EmitAndSemanticDiagnosticsBuilderProgram;
}
export function createWatchOfConfigFile(configFileName: string, host: WatchedSystem, maxNumberOfFilesToIterateForInvalidation?: number) {
const compilerHost = createWatchCompilerHostOfConfigFile(configFileName, {}, host);
compilerHost.maxNumberOfFilesToIterateForInvalidation = maxNumberOfFilesToIterateForInvalidation;
const watch = createWatchProgram(compilerHost);
- return () => watch.getCurrentProgram().getProgram();
+ const result = (() => watch.getCurrentProgram().getProgram()) as Watch;
+ result.getBuilderProgram = () => watch.getCurrentProgram();
+ return result;
}
export function createWatchOfFilesAndCompilerOptions(rootFiles: string[], host: WatchedSystem, options: CompilerOptions = {}, maxNumberOfFilesToIterateForInvalidation?: number) {
@@ -152,7 +152,21 @@ namespace ts.tscWatch {
assert.equal(host.exitCode, expectedExitCode);
}
- export function getDiagnosticOfFileFrom(file: SourceFile | undefined, text: string, start: number | undefined, length: number | undefined, message: DiagnosticMessage): Diagnostic {
+ function isDiagnosticMessageChain(message: DiagnosticMessage | DiagnosticMessageChain): message is DiagnosticMessageChain {
+ return !!(message as DiagnosticMessageChain).messageText;
+ }
+
+ export function getDiagnosticOfFileFrom(file: SourceFile | undefined, start: number | undefined, length: number | undefined, message: DiagnosticMessage | DiagnosticMessageChain, ..._args: (string | number)[]): Diagnostic {
+ let text: DiagnosticMessageChain | string;
+ if (isDiagnosticMessageChain(message)) {
+ text = message;
+ }
+ else {
+ text = getLocaleSpecificMessage(message);
+ if (arguments.length > 4) {
+ text = formatStringFromArgs(text, arguments, 4);
+ }
+ }
return {
file,
start,
@@ -164,35 +178,17 @@ namespace ts.tscWatch {
};
}
- export function getDiagnosticWithoutFile(message: DiagnosticMessage, ..._args: (string | number)[]): Diagnostic {
- let text = getLocaleSpecificMessage(message);
-
- if (arguments.length > 1) {
- text = formatStringFromArgs(text, arguments, 1);
- }
-
- return getDiagnosticOfFileFrom(/*file*/ undefined, text, /*start*/ undefined, /*length*/ undefined, message);
+ export function getDiagnosticWithoutFile(message: DiagnosticMessage | DiagnosticMessageChain, ...args: (string | number)[]): Diagnostic {
+ return getDiagnosticOfFileFrom(/*file*/ undefined, /*start*/ undefined, /*length*/ undefined, message, ...args);
}
- export function getDiagnosticOfFile(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ..._args: (string | number)[]): Diagnostic {
- let text = getLocaleSpecificMessage(message);
-
- if (arguments.length > 4) {
- text = formatStringFromArgs(text, arguments, 4);
- }
-
- return getDiagnosticOfFileFrom(file, text, start, length, message);
+ export function getDiagnosticOfFile(file: SourceFile, start: number, length: number, message: DiagnosticMessage | DiagnosticMessageChain, ...args: (string | number)[]): Diagnostic {
+ return getDiagnosticOfFileFrom(file, start, length, message, ...args);
}
- export function getDiagnosticOfFileFromProgram(program: Program, filePath: string, start: number, length: number, message: DiagnosticMessage, ..._args: (string | number)[]): Diagnostic {
- let text = getLocaleSpecificMessage(message);
-
- if (arguments.length > 5) {
- text = formatStringFromArgs(text, arguments, 5);
- }
-
+ export function getDiagnosticOfFileFromProgram(program: Program, filePath: string, start: number, length: number, message: DiagnosticMessage | DiagnosticMessageChain, ...args: (string | number)[]): Diagnostic {
return getDiagnosticOfFileFrom(program.getSourceFileByPath(toPath(filePath, program.getCurrentDirectory(), s => s.toLowerCase()))!,
- text, start, length, message);
+ start, length, message, ...args);
}
export function getUnknownCompilerOption(program: Program, configFile: File, option: string) {
diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts
index 6109db5a341..b322c08bfe7 100644
--- a/src/testRunner/unittests/tscWatch/programUpdates.ts
+++ b/src/testRunner/unittests/tscWatch/programUpdates.ts
@@ -1070,92 +1070,6 @@ export default test;`;
}
});
- it("updates errors when deep import file changes", () => {
- const currentDirectory = "/user/username/projects/myproject";
- const aFile: File = {
- path: `${currentDirectory}/a.ts`,
- content: `import {B} from './b';
-declare var console: any;
-let b = new B();
-console.log(b.c.d);`
- };
- const bFile: File = {
- path: `${currentDirectory}/b.ts`,
- content: `import {C} from './c';
-export class B
-{
- c = new C();
-}`
- };
- const cFile: File = {
- path: `${currentDirectory}/c.ts`,
- content: `export class C
-{
- d = 1;
-}`
- };
- const config: File = {
- path: `${currentDirectory}/tsconfig.json`,
- content: `{}`
- };
- const files = [aFile, bFile, cFile, config, libFile];
- const host = createWatchedSystem(files, { currentDirectory });
- const watch = createWatchOfConfigFile("tsconfig.json", host);
- checkProgramActualFiles(watch(), [aFile.path, bFile.path, cFile.path, libFile.path]);
- checkOutputErrorsInitial(host, emptyArray);
- const modifiedTimeOfAJs = host.getModifiedTime(`${currentDirectory}/a.js`);
- host.writeFile(cFile.path, cFile.content.replace("d", "d2"));
- host.runQueuedTimeoutCallbacks();
- checkOutputErrorsIncremental(host, [
- getDiagnosticOfFileFromProgram(watch(), aFile.path, aFile.content.lastIndexOf("d"), 1, Diagnostics.Property_0_does_not_exist_on_type_1, "d", "C")
- ]);
- // File a need not be rewritten
- assert.equal(host.getModifiedTime(`${currentDirectory}/a.js`), modifiedTimeOfAJs);
- });
-
- it("updates errors when deep import through declaration file changes", () => {
- const currentDirectory = "/user/username/projects/myproject";
- const aFile: File = {
- path: `${currentDirectory}/a.ts`,
- content: `import {B} from './b';
-declare var console: any;
-let b = new B();
-console.log(b.c.d);`
- };
- const bFile: File = {
- path: `${currentDirectory}/b.d.ts`,
- content: `import {C} from './c';
-export class B
-{
- c: C;
-}`
- };
- const cFile: File = {
- path: `${currentDirectory}/c.d.ts`,
- content: `export class C
-{
- d: number;
-}`
- };
- const config: File = {
- path: `${currentDirectory}/tsconfig.json`,
- content: `{}`
- };
- const files = [aFile, bFile, cFile, config, libFile];
- const host = createWatchedSystem(files, { currentDirectory });
- const watch = createWatchOfConfigFile("tsconfig.json", host);
- checkProgramActualFiles(watch(), [aFile.path, bFile.path, cFile.path, libFile.path]);
- checkOutputErrorsInitial(host, emptyArray);
- const modifiedTimeOfAJs = host.getModifiedTime(`${currentDirectory}/a.js`);
- host.writeFile(cFile.path, cFile.content.replace("d", "d2"));
- host.runQueuedTimeoutCallbacks();
- checkOutputErrorsIncremental(host, [
- getDiagnosticOfFileFromProgram(watch(), aFile.path, aFile.content.lastIndexOf("d"), 1, Diagnostics.Property_0_does_not_exist_on_type_1, "d", "C")
- ]);
- // File a need not be rewritten
- assert.equal(host.getModifiedTime(`${currentDirectory}/a.js`), modifiedTimeOfAJs);
- });
-
it("updates errors when strictNullChecks changes", () => {
const currentDirectory = "/user/username/projects/myproject";
const aFile: File = {
@@ -1228,98 +1142,6 @@ foo().hello`
checkOutputErrorsIncremental(host, emptyArray);
});
- describe("updates errors when file transitively exported file changes", () => {
- const projectLocation = "/user/username/projects/myproject";
- const config: File = {
- path: `${projectLocation}/tsconfig.json`,
- content: JSON.stringify({
- files: ["app.ts"],
- compilerOptions: { baseUrl: "." }
- })
- };
- const app: File = {
- path: `${projectLocation}/app.ts`,
- content: `import { Data } from "lib2/public";
-export class App {
- public constructor() {
- new Data().test();
- }
-}`
- };
- const lib2Public: File = {
- path: `${projectLocation}/lib2/public.ts`,
- content: `export * from "./data";`
- };
- const lib2Data: File = {
- path: `${projectLocation}/lib2/data.ts`,
- content: `import { ITest } from "lib1/public";
-export class Data {
- public test() {
- const result: ITest = {
- title: "title"
- }
- return result;
- }
-}`
- };
- const lib1Public: File = {
- path: `${projectLocation}/lib1/public.ts`,
- content: `export * from "./tools/public";`
- };
- const lib1ToolsPublic: File = {
- path: `${projectLocation}/lib1/tools/public.ts`,
- content: `export * from "./tools.interface";`
- };
- const lib1ToolsInterface: File = {
- path: `${projectLocation}/lib1/tools/tools.interface.ts`,
- content: `export interface ITest {
- title: string;
-}`
- };
-
- function verifyTransitiveExports(filesWithoutConfig: ReadonlyArray) {
- const files = [config, ...filesWithoutConfig];
- const host = createWatchedSystem(files, { currentDirectory: projectLocation });
- const watch = createWatchOfConfigFile(config.path, host);
- checkProgramActualFiles(watch(), filesWithoutConfig.map(f => f.path));
- checkOutputErrorsInitial(host, emptyArray);
-
- host.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title", "title2"));
- host.checkTimeoutQueueLengthAndRun(1);
- checkProgramActualFiles(watch(), filesWithoutConfig.map(f => f.path));
- checkOutputErrorsIncremental(host, [
- "lib2/data.ts(5,13): error TS2322: Type '{ title: string; }' is not assignable to type 'ITest'.\n Object literal may only specify known properties, but 'title' does not exist in type 'ITest'. Did you mean to write 'title2'?\n"
- ]);
-
- }
- it("when there are no circular import and exports", () => {
- verifyTransitiveExports([libFile, app, lib2Public, lib2Data, lib1Public, lib1ToolsPublic, lib1ToolsInterface]);
- });
-
- it("when there are circular import and exports", () => {
- const lib2Data: File = {
- path: `${projectLocation}/lib2/data.ts`,
- content: `import { ITest } from "lib1/public"; import { Data2 } from "./data2";
-export class Data {
- public dat?: Data2; public test() {
- const result: ITest = {
- title: "title"
- }
- return result;
- }
-}`
- };
- const lib2Data2: File = {
- path: `${projectLocation}/lib2/data2.ts`,
- content: `import { Data } from "./data";
-export class Data2 {
- public dat?: Data;
-}`
- };
- verifyTransitiveExports([libFile, app, lib2Public, lib2Data, lib2Data2, lib1Public, lib1ToolsPublic, lib1ToolsInterface]);
- });
- });
-
describe("updates errors in lib file", () => {
const currentDirectory = "/user/username/projects/myproject";
const field = "fullscreen";
@@ -1459,7 +1281,59 @@ interface Document {
checkProgramActualFiles(watch(), [aFile.path, bFile.path, libFile.path]);
}
});
+
+ it("reports errors correctly with isolatedModules", () => {
+ const currentDirectory = "/user/username/projects/myproject";
+ const aFile: File = {
+ path: `${currentDirectory}/a.ts`,
+ content: `export const a: string = "";`
+ };
+ const bFile: File = {
+ path: `${currentDirectory}/b.ts`,
+ content: `import { a } from "./a";
+const b: string = a;`
+ };
+ const configFile: File = {
+ path: `${currentDirectory}/tsconfig.json`,
+ content: JSON.stringify({
+ compilerOptions: {
+ isolatedModules: true
+ }
+ })
+ };
+
+ const files = [aFile, bFile, libFile, configFile];
+
+ const host = createWatchedSystem(files, { currentDirectory });
+ const watch = createWatchOfConfigFile("tsconfig.json", host);
+ verifyProgramFiles();
+ checkOutputErrorsInitial(host, emptyArray);
+ assert.equal(host.readFile(`${currentDirectory}/a.js`), `"use strict";
+exports.__esModule = true;
+exports.a = "";
+`, "Contents of a.js");
+ assert.equal(host.readFile(`${currentDirectory}/b.js`), `"use strict";
+exports.__esModule = true;
+var a_1 = require("./a");
+var b = a_1.a;
+`, "Contents of b.js");
+ const modifiedTime = host.getModifiedTime(`${currentDirectory}/b.js`);
+
+ host.writeFile(aFile.path, `export const a: number = 1`);
+ host.runQueuedTimeoutCallbacks();
+ verifyProgramFiles();
+ checkOutputErrorsIncremental(host, [
+ getDiagnosticOfFileFromProgram(watch(), bFile.path, bFile.content.indexOf("b"), 1, Diagnostics.Type_0_is_not_assignable_to_type_1, "number", "string")
+ ]);
+ assert.equal(host.readFile(`${currentDirectory}/a.js`), `"use strict";
+exports.__esModule = true;
+exports.a = 1;
+`, "Contents of a.js");
+ assert.equal(host.getModifiedTime(`${currentDirectory}/b.js`), modifiedTime, "Timestamp of b.js");
+
+ function verifyProgramFiles() {
+ checkProgramActualFiles(watch(), [aFile.path, bFile.path, libFile.path]);
+ }
+ });
});
-
-
}
diff --git a/src/testRunner/unittests/tsserver/externalProjects.ts b/src/testRunner/unittests/tsserver/externalProjects.ts
index 12a97151f4e..2055141538a 100644
--- a/src/testRunner/unittests/tsserver/externalProjects.ts
+++ b/src/testRunner/unittests/tsserver/externalProjects.ts
@@ -760,5 +760,63 @@ namespace ts.projectSystem {
assert.equal(project2.pendingReload, ConfigFileProgramReloadLevel.None); // External project referenced configured project loaded
checkProjectActualFiles(project2, [config.path, f1.path]);
});
+
+ it("handles creation of external project with jsconfig before jsconfig creation watcher is invoked", () => {
+ const projectLocation = `/user/username/projects/WebApplication36/WebApplication36`;
+ const projectFileName = `${projectLocation}/WebApplication36.csproj`;
+ const tsconfig: File = {
+ path: `${projectLocation}/tsconfig.json`,
+ content: "{}"
+ };
+ const files = [libFile, tsconfig];
+ const host = createServerHost(files);
+ const service = createProjectService(host);
+
+ // Create external project
+ service.openExternalProjects([{
+ projectFileName,
+ rootFiles: [{ fileName: tsconfig.path }],
+ options: { allowJs: false }
+ }]);
+ checkNumberOfProjects(service, { configuredProjects: 1 });
+ const configProject = service.configuredProjects.get(tsconfig.path.toLowerCase())!;
+ checkProjectActualFiles(configProject, [tsconfig.path]);
+
+ // write js file, open external project and open it for edit
+ const jsFilePath = `${projectLocation}/javascript.js`;
+ host.writeFile(jsFilePath, "");
+ service.openExternalProjects([{
+ projectFileName,
+ rootFiles: [{ fileName: tsconfig.path }, { fileName: jsFilePath }],
+ options: { allowJs: false }
+ }]);
+ service.applyChangesInOpenFiles([
+ { fileName: jsFilePath, scriptKind: ScriptKind.JS, content: "" }
+ ], /*changedFiles*/ undefined, /*closedFiles*/ undefined);
+ checkNumberOfProjects(service, { configuredProjects: 1, inferredProjects: 1 });
+ checkProjectActualFiles(configProject, [tsconfig.path]);
+ const inferredProject = service.inferredProjects[0];
+ checkProjectActualFiles(inferredProject, [libFile.path, jsFilePath]);
+
+ // write jsconfig file
+ const jsConfig: File = {
+ path: `${projectLocation}/jsconfig.json`,
+ content: "{}"
+ };
+ // Dont invoke file creation watchers as the repro suggests
+ host.ensureFileOrFolder(jsConfig, /*ignoreWatchInvokedWithTriggerAsFileCreate*/ true);
+
+ // Open external project
+ service.openExternalProjects([{
+ projectFileName,
+ rootFiles: [{ fileName: jsConfig.path }, { fileName: tsconfig.path }, { fileName: jsFilePath }],
+ options: { allowJs: false }
+ }]);
+ checkNumberOfProjects(service, { configuredProjects: 2, inferredProjects: 1 });
+ checkProjectActualFiles(configProject, [tsconfig.path]);
+ assert.isTrue(inferredProject.isOrphan());
+ const jsConfigProject = service.configuredProjects.get(jsConfig.path.toLowerCase())!;
+ checkProjectActualFiles(jsConfigProject, [jsConfig.path, jsFilePath, libFile.path]);
+ });
});
}
diff --git a/src/testRunner/unittests/tsserver/helpers.ts b/src/testRunner/unittests/tsserver/helpers.ts
index 1db6a9b36c8..3e79451cd11 100644
--- a/src/testRunner/unittests/tsserver/helpers.ts
+++ b/src/testRunner/unittests/tsserver/helpers.ts
@@ -57,8 +57,8 @@ namespace ts.projectSystem {
export const nullLogger: server.Logger = {
close: noop,
- hasLevel: () => false,
- loggingEnabled: () => false,
+ hasLevel: returnFalse,
+ loggingEnabled: returnFalse,
perftrc: noop,
info: noop,
msg: noop,
@@ -80,6 +80,21 @@ namespace ts.projectSystem {
return { logger, hasErrorMsg: () => hasErrorMsg };
}
+ export function createLoggerWritingToConsole(): server.Logger {
+ const { close, startGroup, endGroup, getLogFileName } = nullLogger;
+ return {
+ close,
+ hasLevel: returnTrue,
+ loggingEnabled: returnTrue,
+ perftrc: s => console.log(s),
+ info: s => console.log(s),
+ msg: (s, type) => console.log(`${type}:: ${s}`),
+ startGroup,
+ endGroup,
+ getLogFileName
+ };
+ }
+
export class TestTypingsInstaller extends TI.TypingsInstaller implements server.ITypingsInstaller {
protected projectService!: server.ProjectService;
constructor(
diff --git a/src/testRunner/unittests/tsserver/projects.ts b/src/testRunner/unittests/tsserver/projects.ts
index 00941a1d3c9..3a648c9189e 100644
--- a/src/testRunner/unittests/tsserver/projects.ts
+++ b/src/testRunner/unittests/tsserver/projects.ts
@@ -103,6 +103,30 @@ namespace ts.projectSystem {
assert.isFalse(proj3.languageServiceEnabled);
});
+ it("should not crash when opening a file in a project with a disabled language service", () => {
+ const file1 = {
+ path: "/a/b/f1.js",
+ content: "let x =1;",
+ fileSize: 50 * 1024 * 1024
+ };
+ const file2 = {
+ path: "/a/b/f2.js",
+ content: "let x =1;",
+ fileSize: 100
+ };
+
+ const projName = "proj1";
+
+ const host = createServerHost([file1, file2]);
+ const projectService = createProjectService(host, { useSingleInferredProject: true }, { eventHandler: noop });
+
+ projectService.openExternalProject({ rootFiles: toExternalFiles([file1.path, file2.path]), options: {}, projectFileName: projName });
+ const proj1 = projectService.findProject(projName)!;
+ assert.isFalse(proj1.languageServiceEnabled);
+
+ assert.doesNotThrow(() => projectService.openClientFile(file2.path));
+ });
+
describe("ignoreConfigFiles", () => {
it("external project including config file", () => {
const file1 = {
diff --git a/src/testRunner/unittests/tsserver/refactors.ts b/src/testRunner/unittests/tsserver/refactors.ts
index 2f4531f61a5..04eb552c316 100644
--- a/src/testRunner/unittests/tsserver/refactors.ts
+++ b/src/testRunner/unittests/tsserver/refactors.ts
@@ -116,5 +116,40 @@ namespace ts.projectSystem {
renameLocation: undefined,
});
});
+
+ it("handles canonicalization of tsconfig path", () => {
+ const aTs: File = { path: "/Foo/a.ts", content: "const x = 0;" };
+ const tsconfig: File = { path: "/Foo/tsconfig.json", content: '{ "files": ["./a.ts"] }' };
+ const session = createSession(createServerHost([aTs, tsconfig]));
+ openFilesForSession([aTs], session);
+
+ const result = executeSessionRequest(session, protocol.CommandTypes.GetEditsForRefactor, {
+ file: aTs.path,
+ startLine: 1,
+ startOffset: 1,
+ endLine: 2,
+ endOffset: aTs.content.length,
+ refactor: "Move to a new file",
+ action: "Move to a new file",
+ });
+ assert.deepEqual(result, {
+ edits: [
+ {
+ fileName: aTs.path,
+ textChanges: [{ start: { line: 1, offset: 1 }, end: { line: 1, offset: aTs.content.length + 1 }, newText: "" }],
+ },
+ {
+ fileName: tsconfig.path,
+ textChanges: [{ start: { line: 1, offset: 21 }, end: { line: 1, offset: 21 }, newText: ', "./x.ts"' }],
+ },
+ {
+ fileName: "/Foo/x.ts",
+ textChanges: [{ start: { line: 0, offset: 0 }, end: { line: 0, offset: 0 }, newText: "const x = 0;\n" }],
+ },
+ ],
+ renameFilename: undefined,
+ renameLocation: undefined,
+ });
+ });
});
}
diff --git a/src/testRunner/unittests/tsserver/rename.ts b/src/testRunner/unittests/tsserver/rename.ts
index 75c08bb8bb0..4e95e79e31f 100644
--- a/src/testRunner/unittests/tsserver/rename.ts
+++ b/src/testRunner/unittests/tsserver/rename.ts
@@ -7,8 +7,18 @@ namespace ts.projectSystem {
const session = createSession(createServerHost([aTs, bTs]));
openFilesForSession([bTs], session);
- const response = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";'));
- assert.deepEqual(response, {
+ const response1 = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";'));
+ assert.deepEqual(response1, {
+ info: {
+ canRename: false,
+ localizedErrorMessage: "You cannot rename this element."
+ },
+ locs: [{ file: bTs.path, locs: [protocolRenameSpanFromSubstring(bTs.content, "./a")] }],
+ });
+
+ session.getProjectService().setHostConfiguration({ preferences: { allowRenameOfImportPath: true } });
+ const response2 = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";'));
+ assert.deepEqual(response2, {
info: {
canRename: true,
fileToRename: aTs.path,
diff --git a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt
index 3a03491f110..1fde67722db 100644
--- a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt
+++ b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt
@@ -1,8 +1,8 @@
-tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2568: Type 'Set' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
+tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts (1 errors) ====
var union: string | Set
for (const e of union) { }
~~~~~
-!!! error TS2568: Type 'Set' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
\ No newline at end of file
+!!! error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
\ No newline at end of file
diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts
index d8ad3955edc..f60bf3346db 100644
--- a/tests/baselines/reference/api/tsserverlibrary.d.ts
+++ b/tests/baselines/reference/api/tsserverlibrary.d.ts
@@ -4707,7 +4707,7 @@ declare namespace ts {
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined;
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined;
getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined;
- getRenameInfo(fileName: string, position: number): RenameInfo;
+ getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo;
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined;
getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined;
getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined;
@@ -5151,6 +5151,9 @@ declare namespace ts {
canRename: false;
localizedErrorMessage: string;
}
+ interface RenameInfoOptions {
+ readonly allowRenameOfImportPath?: boolean;
+ }
interface SignatureHelpParameter {
name: string;
documentation: SymbolDisplayPart[];
@@ -7924,6 +7927,7 @@ declare namespace ts.server.protocol {
readonly importModuleSpecifierPreference?: "relative" | "non-relative";
readonly allowTextChangesInNewFiles?: boolean;
readonly lazyConfiguredProjectsFromExternalProject?: boolean;
+ readonly allowRenameOfImportPath?: boolean;
}
interface CompilerOptions {
allowJs?: boolean;
diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts
index 7465a4500cc..f005bfe168d 100644
--- a/tests/baselines/reference/api/typescript.d.ts
+++ b/tests/baselines/reference/api/typescript.d.ts
@@ -4707,7 +4707,7 @@ declare namespace ts {
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined;
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined;
getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined;
- getRenameInfo(fileName: string, position: number): RenameInfo;
+ getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo;
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined;
getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined;
getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined;
@@ -5151,6 +5151,9 @@ declare namespace ts {
canRename: false;
localizedErrorMessage: string;
}
+ interface RenameInfoOptions {
+ readonly allowRenameOfImportPath?: boolean;
+ }
interface SignatureHelpParameter {
name: string;
documentation: SymbolDisplayPart[];
diff --git a/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt
index b401345a5e1..0f44d023a76 100644
--- a/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt
+++ b/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt
@@ -1,6 +1,4 @@
-tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
- Types of property 'children' are incompatible.
- Type 'Element[]' is missing the following properties from type 'Element': type, props
+tests/cases/conformance/jsx/file.tsx(42,11): error TS2746: This JSX tag's 'children' prop expects a single child of type 'Element', but multiple children were provided.
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
@@ -47,6 +45,4 @@ tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Ele
// Error
let k5 = <>>;
~~~~~~~~~~~~~~~
-!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type 'Element[]' is missing the following properties from type 'Element': type, props
\ No newline at end of file
+!!! error TS2746: This JSX tag's 'children' prop expects a single child of type 'Element', but multiple children were provided.
\ No newline at end of file
diff --git a/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt
index e2931b3fb5d..b289fb97d2b 100644
--- a/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt
+++ b/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt
@@ -1,21 +1,9 @@
tests/cases/conformance/jsx/file.tsx(14,10): error TS2741: Property 'children' is missing in type '{ a: number; b: string; }' but required in type 'Prop'.
tests/cases/conformance/jsx/file.tsx(17,11): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
-tests/cases/conformance/jsx/file.tsx(31,6): error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
- Types of property 'children' are incompatible.
- Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
- Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string'.
-tests/cases/conformance/jsx/file.tsx(37,6): error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
- Types of property 'children' are incompatible.
- Type '(number | Element)[]' is not assignable to type 'string | Element'.
- Type '(number | Element)[]' is not assignable to type 'string'.
-tests/cases/conformance/jsx/file.tsx(43,6): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
- Types of property 'children' are incompatible.
- Type '(string | Element)[]' is not assignable to type 'string | Element'.
- Type '(string | Element)[]' is not assignable to type 'string'.
-tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
- Types of property 'children' are incompatible.
- Type 'Element[]' is not assignable to type 'string | Element'.
- Type 'Element[]' is not assignable to type 'string'.
+tests/cases/conformance/jsx/file.tsx(31,6): error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
+tests/cases/conformance/jsx/file.tsx(37,6): error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
+tests/cases/conformance/jsx/file.tsx(43,6): error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
+tests/cases/conformance/jsx/file.tsx(49,6): error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
==== tests/cases/conformance/jsx/file.tsx (6 errors) ====
@@ -56,10 +44,7 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Elem
let k2 =
~~~~
-!!! error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
-!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string'.
+!!! error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
My Div
{(name: string) =>
My name {name}
}
;
@@ -67,10 +52,7 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Elem
let k3 =
~~~~
-!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'string | Element'.
-!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'string'.
+!!! error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
My Div
{1000000}
;
@@ -78,10 +60,7 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Elem
let k4 =
~~~~
-!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'string | Element'.
-!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'string'.
+!!! error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
My Div
hi hi hi!
;
@@ -89,10 +68,7 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Elem
let k5 =
~~~~
-!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type 'Element[]' is not assignable to type 'string | Element'.
-!!! error TS2322: Type 'Element[]' is not assignable to type 'string'.
+!!! error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
My Div
My Div
;
\ No newline at end of file
diff --git a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt
index 8e7a3adb518..34bd2189964 100644
--- a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt
+++ b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt
@@ -1,11 +1,11 @@
tests/cases/conformance/jsx/file.tsx(24,28): error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'?
-tests/cases/conformance/jsx/file.tsx(32,10): error TS2322: Type '{ children: (((user: IUser) => Element) | ((user: IUser) => Element))[]; }' is not assignable to type 'IFetchUserProps'.
- Types of property 'children' are incompatible.
- Type '(((user: IUser) => Element) | ((user: IUser) => Element))[]' is not assignable to type '(user: IUser) => Element'.
- Type '(((user: IUser) => Element) | ((user: IUser) => Element))[]' provides no match for the signature '(user: IUser): Element'.
+tests/cases/conformance/jsx/file.tsx(36,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement'.
+ Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement': type, props
+tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement'.
+ Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement': type, props
-==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
+==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
import React = require('react');
interface IUser {
@@ -41,20 +41,27 @@ tests/cases/conformance/jsx/file.tsx(32,10): error TS2322: Type '{ children: (((
function UserName1() {
return (
- ~~~~~~~~~
-!!! error TS2322: Type '{ children: (((user: IUser) => Element) | ((user: IUser) => Element))[]; }' is not assignable to type 'IFetchUserProps'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type '(((user: IUser) => Element) | ((user: IUser) => Element))[]' is not assignable to type '(user: IUser) => Element'.
-!!! error TS2322: Type '(((user: IUser) => Element) | ((user: IUser) => Element))[]' provides no match for the signature '(user: IUser): Element'.
{ user => (
+ ~~~~~~~~~
{ user.Name }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
) }
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement'.
+!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement': type, props
+!!! related TS6212 tests/cases/conformance/jsx/file.tsx:36:15: Did you mean to call this expression?
{ user => (
+ ~~~~~~~~~
{ user.Name }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
) }
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement'.
+!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement': type, props
+!!! related TS6212 tests/cases/conformance/jsx/file.tsx:39:15: Did you mean to call this expression?
);
}
\ No newline at end of file
diff --git a/tests/baselines/reference/checkJsxChildrenProperty5.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty5.errors.txt
index 536d1e65483..476644ee336 100644
--- a/tests/baselines/reference/checkJsxChildrenProperty5.errors.txt
+++ b/tests/baselines/reference/checkJsxChildrenProperty5.errors.txt
@@ -1,10 +1,6 @@
tests/cases/conformance/jsx/file.tsx(20,10): error TS2741: Property 'children' is missing in type '{ a: number; b: string; }' but required in type 'Prop'.
-tests/cases/conformance/jsx/file.tsx(24,6): error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'Prop'.
- Types of property 'children' are incompatible.
- Type 'Element' is missing the following properties from type 'Button': render, setState, forceUpdate, state, and 2 more.
-tests/cases/conformance/jsx/file.tsx(28,6): error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'Prop'.
- Types of property 'children' are incompatible.
- Type 'typeof Button' is missing the following properties from type 'Button': render, setState, forceUpdate, props, and 3 more.
+tests/cases/conformance/jsx/file.tsx(25,9): error TS2740: Type 'Element' is missing the following properties from type 'Button': render, setState, forceUpdate, state, and 2 more.
+tests/cases/conformance/jsx/file.tsx(29,10): error TS2740: Type 'typeof Button' is missing the following properties from type 'Button': render, setState, forceUpdate, props, and 3 more.
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
@@ -35,17 +31,15 @@ tests/cases/conformance/jsx/file.tsx(28,6): error TS2322: Type '{ children: type
// Error: JSX.element is not the same as JSX.ElementClass
let k1 =
- ~~~~
-!!! error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'Prop'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type 'Element' is missing the following properties from type 'Button': render, setState, forceUpdate, state, and 2 more.
+ ~~~~~~~~~~
+!!! error TS2740: Type 'Element' is missing the following properties from type 'Button': render, setState, forceUpdate, state, and 2 more.
+!!! related TS6500 tests/cases/conformance/jsx/file.tsx:6:5: The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & Prop'
;
let k2 =
- ~~~~
-!!! error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'Prop'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type 'typeof Button' is missing the following properties from type 'Button': render, setState, forceUpdate, props, and 3 more.
{Button}
+ ~~~~~~
+!!! error TS2740: Type 'typeof Button' is missing the following properties from type 'Button': render, setState, forceUpdate, props, and 3 more.
+!!! related TS6213 tests/cases/conformance/jsx/file.tsx:29:10: Did you mean to use 'new' with this expression?
;
\ No newline at end of file
diff --git a/tests/baselines/reference/checkJsxChildrenProperty7.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty7.errors.txt
index 6a2325cb827..0197bc6cd41 100644
--- a/tests/baselines/reference/checkJsxChildrenProperty7.errors.txt
+++ b/tests/baselines/reference/checkJsxChildrenProperty7.errors.txt
@@ -1,17 +1,6 @@
-tests/cases/conformance/jsx/file.tsx(24,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
- Types of property 'children' are incompatible.
- Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
- Type '(string | Element)[]' is not assignable to type 'Element[]'.
- Type 'string | Element' is not assignable to type 'Element'.
- Type 'string' is not assignable to type 'Element'.
-tests/cases/conformance/jsx/file.tsx(25,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
- Types of property 'children' are incompatible.
- Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
- Type '(string | Element)[]' is not assignable to type 'Element[]'.
-tests/cases/conformance/jsx/file.tsx(27,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
- Types of property 'children' are incompatible.
- Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
- Type '(string | Element)[]' is not assignable to type 'Element[]'.
+tests/cases/conformance/jsx/file.tsx(24,40): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | Element[]'.
+tests/cases/conformance/jsx/file.tsx(26,22): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | Element[]'.
+tests/cases/conformance/jsx/file.tsx(27,30): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | Element[]'.
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
@@ -39,24 +28,13 @@ tests/cases/conformance/jsx/file.tsx(27,11): error TS2322: Type '{ children: (st
// Error: whitespaces matters
let k1 = ;
- ~~~~
-!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
-!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
-!!! error TS2322: Type 'string | Element' is not assignable to type 'Element'.
-!!! error TS2322: Type 'string' is not assignable to type 'Element'.
+ ~~
+!!! error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | Element[]'.
let k2 =
- ~~~~
-!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
-!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
;
+ ~~
+!!! error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | Element[]'.
let k3 =
- ~~~~
-!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
-!!! error TS2322: Types of property 'children' are incompatible.
-!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
-!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
+ ~~~~
+!!! error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | Element[]'.
;
\ No newline at end of file
diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.errors.txt b/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.errors.txt
new file mode 100644
index 00000000000..5d67f88c847
--- /dev/null
+++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.errors.txt
@@ -0,0 +1,22 @@
+tests/cases/compiler/noSuperInJSDocExtends.js(14,9): error TS2335: 'super' can only be referenced in a derived class.
+
+
+==== tests/cases/compiler/noSuperInJSDocExtends.js (1 errors) ====
+ class Based { }
+ /** @extends {Based} */
+ class Derived {
+ constructor() {
+ this;
+ this.x = 10;
+ var that = this;
+ }
+ }
+
+ /** @extends {Based} */
+ class Derived2 {
+ constructor() {
+ super();
+ ~~~~~
+!!! error TS2335: 'super' can only be referenced in a derived class.
+ }
+ }
\ No newline at end of file
diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.symbols b/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.symbols
new file mode 100644
index 00000000000..f900a4986eb
--- /dev/null
+++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.symbols
@@ -0,0 +1,31 @@
+=== tests/cases/compiler/noSuperInJSDocExtends.js ===
+class Based { }
+>Based : Symbol(Based, Decl(noSuperInJSDocExtends.js, 0, 0))
+
+/** @extends {Based} */
+class Derived {
+>Derived : Symbol(Derived, Decl(noSuperInJSDocExtends.js, 0, 15))
+
+ constructor() {
+ this;
+>this : Symbol(Derived, Decl(noSuperInJSDocExtends.js, 0, 15))
+
+ this.x = 10;
+>this.x : Symbol(Derived.x, Decl(noSuperInJSDocExtends.js, 4, 13))
+>this : Symbol(Derived, Decl(noSuperInJSDocExtends.js, 0, 15))
+>x : Symbol(Derived.x, Decl(noSuperInJSDocExtends.js, 4, 13))
+
+ var that = this;
+>that : Symbol(that, Decl(noSuperInJSDocExtends.js, 6, 11))
+>this : Symbol(Derived, Decl(noSuperInJSDocExtends.js, 0, 15))
+ }
+}
+
+/** @extends {Based} */
+class Derived2 {
+>Derived2 : Symbol(Derived2, Decl(noSuperInJSDocExtends.js, 8, 1))
+
+ constructor() {
+ super();
+ }
+}
diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.types
new file mode 100644
index 00000000000..577256400b2
--- /dev/null
+++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.types
@@ -0,0 +1,35 @@
+=== tests/cases/compiler/noSuperInJSDocExtends.js ===
+class Based { }
+>Based : Based
+
+/** @extends {Based} */
+class Derived {
+>Derived : Derived
+
+ constructor() {
+ this;
+>this : this
+
+ this.x = 10;
+>this.x = 10 : 10
+>this.x : number
+>this : this
+>x : number
+>10 : 10
+
+ var that = this;
+>that : this
+>this : this
+ }
+}
+
+/** @extends {Based} */
+class Derived2 {
+>Derived2 : Derived2
+
+ constructor() {
+ super();
+>super() : void
+>super : any
+ }
+}
diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt
index 8bf05c043ce..62239eca7b8 100644
--- a/tests/baselines/reference/conditionalTypes1.errors.txt
+++ b/tests/baselines/reference/conditionalTypes1.errors.txt
@@ -471,4 +471,12 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
var a = {o: 1, b: 2, c: [{a: 1, c: '213'}]}
assign(a, {o: 2, c: {0: {a: 2, c: '213123'}}})
+
+ // Repros from #23843
+
+ type Weird1 = ((a: U) => never) extends
+ ((a: U) => never) ? never : never;
+
+ type Weird2 = ((a: U) => U) extends
+ ((a: U) => infer T) ? T : never;
\ No newline at end of file
diff --git a/tests/baselines/reference/conditionalTypes1.js b/tests/baselines/reference/conditionalTypes1.js
index 552a80d58a5..7ce19ce17e7 100644
--- a/tests/baselines/reference/conditionalTypes1.js
+++ b/tests/baselines/reference/conditionalTypes1.js
@@ -351,6 +351,14 @@ declare function assign(o: T, a: RecursivePartial): void;
var a = {o: 1, b: 2, c: [{a: 1, c: '213'}]}
assign(a, {o: 2, c: {0: {a: 2, c: '213123'}}})
+
+// Repros from #23843
+
+type Weird1 = ((a: U) => never) extends
+ ((a: U) => never) ? never : never;
+
+type Weird2 = ((a: U) => U) extends
+ ((a: U) => infer T) ? T : never;
//// [conditionalTypes1.js]
@@ -715,3 +723,5 @@ declare var a: {
c: string;
}[];
};
+declare type Weird1 = ((a: U) => never) extends ((a: U) => never) ? never : never;
+declare type Weird2 = ((a: U) => U) extends ((a: U) => infer T) ? T : never;
diff --git a/tests/baselines/reference/conditionalTypes1.symbols b/tests/baselines/reference/conditionalTypes1.symbols
index 19f0ae83890..e5c6ae3d6c7 100644
--- a/tests/baselines/reference/conditionalTypes1.symbols
+++ b/tests/baselines/reference/conditionalTypes1.symbols
@@ -1371,3 +1371,30 @@ assign(a, {o: 2, c: {0: {a: 2, c: '213123'}}})
>a : Symbol(a, Decl(conditionalTypes1.ts, 351, 25))
>c : Symbol(c, Decl(conditionalTypes1.ts, 351, 30))
+// Repros from #23843
+
+type Weird1 = ((a: U) => never) extends
+>Weird1 : Symbol(Weird1, Decl(conditionalTypes1.ts, 351, 46))
+>U : Symbol(U, Decl(conditionalTypes1.ts, 355, 16))
+>a : Symbol(a, Decl(conditionalTypes1.ts, 355, 35))
+>U : Symbol(U, Decl(conditionalTypes1.ts, 355, 16))
+
+ ((a: U) => never) ? never : never;
+>U : Symbol(U, Decl(conditionalTypes1.ts, 356, 6))
+>a : Symbol(a, Decl(conditionalTypes1.ts, 356, 22))
+>U : Symbol(U, Decl(conditionalTypes1.ts, 356, 6))
+
+type Weird2 = ((a: U) => U) extends
+>Weird2 : Symbol(Weird2, Decl(conditionalTypes1.ts, 356, 54))
+>U : Symbol(U, Decl(conditionalTypes1.ts, 358, 16))
+>a : Symbol(a, Decl(conditionalTypes1.ts, 358, 35))
+>U : Symbol(U, Decl(conditionalTypes1.ts, 358, 16))
+>U : Symbol(U, Decl(conditionalTypes1.ts, 358, 16))
+
+ ((a: U) => infer T) ? T : never;
+>U : Symbol(U, Decl(conditionalTypes1.ts, 359, 6))
+>a : Symbol(a, Decl(conditionalTypes1.ts, 359, 22))
+>U : Symbol(U, Decl(conditionalTypes1.ts, 359, 6))
+>T : Symbol(T, Decl(conditionalTypes1.ts, 359, 36))
+>T : Symbol(T, Decl(conditionalTypes1.ts, 359, 36))
+
diff --git a/tests/baselines/reference/conditionalTypes1.types b/tests/baselines/reference/conditionalTypes1.types
index 00d1965eea4..08fdb4b2f29 100644
--- a/tests/baselines/reference/conditionalTypes1.types
+++ b/tests/baselines/reference/conditionalTypes1.types
@@ -1054,3 +1054,21 @@ assign(a, {o: 2, c: {0: {a: 2, c: '213123'}}})
>c : string
>'213123' : "213123"
+// Repros from #23843
+
+type Weird1 = ((a: U) => never) extends
+>Weird1 : never
+>a : U
+
+ ((a: U) => never) ? never : never;
+>true : true
+>a : U
+
+type Weird2 = ((a: U) => U) extends
+>Weird2 : boolean
+>a : U
+
+ ((a: U) => infer T) ? T : never;
+>true : true
+>a : U
+
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_OutermostOnlyFailure.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_OutermostOnlyFailure.ts
new file mode 100644
index 00000000000..8c3d9745fe8
--- /dev/null
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_OutermostOnlyFailure.ts
@@ -0,0 +1,16 @@
+// ==ORIGINAL==
+
+function foo() {
+ return fetch('a').then(/*[#|*/() => {/*|]*/
+ return fetch('b').then(() => 'c');
+ })
+}
+
+// ==ASYNC FUNCTION::Convert to async function==
+
+function foo() {
+ return fetch('a').then(async () => {
+ await fetch('b');
+ return 'c';
+ })
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_OutermostOnlySuccess.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_OutermostOnlySuccess.js
new file mode 100644
index 00000000000..d710dd925f8
--- /dev/null
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_OutermostOnlySuccess.js
@@ -0,0 +1,15 @@
+// ==ORIGINAL==
+
+function /*[#|*/foo/*|]*/() {
+ return fetch('a').then(() => {
+ return fetch('b').then(() => 'c');
+ })
+}
+
+// ==ASYNC FUNCTION::Convert to async function==
+
+async function foo() {
+ await fetch('a');
+ await fetch('b');
+ return 'c';
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_OutermostOnlySuccess.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_OutermostOnlySuccess.ts
new file mode 100644
index 00000000000..d710dd925f8
--- /dev/null
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_OutermostOnlySuccess.ts
@@ -0,0 +1,15 @@
+// ==ORIGINAL==
+
+function /*[#|*/foo/*|]*/() {
+ return fetch('a').then(() => {
+ return fetch('b').then(() => 'c');
+ })
+}
+
+// ==ASYNC FUNCTION::Convert to async function==
+
+async function foo() {
+ await fetch('a');
+ await fetch('b');
+ return 'c';
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPattern.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPattern.js
index f06ce44e78b..45852e51aee 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPattern.js
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPattern.js
@@ -5,7 +5,7 @@ function /*[#|*/f/*|]*/() {
}
function res({ status, trailer }){
console.log(status);
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -15,4 +15,4 @@ async function f() {
}
function res({ status, trailer }){
console.log(status);
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPattern.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPattern.ts
index f06ce44e78b..45852e51aee 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPattern.ts
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPattern.ts
@@ -5,7 +5,7 @@ function /*[#|*/f/*|]*/() {
}
function res({ status, trailer }){
console.log(status);
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -15,4 +15,4 @@ async function f() {
}
function res({ status, trailer }){
console.log(status);
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPatternNameCollision.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPatternNameCollision.js
index 6813472966a..40488dbe73c 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPatternNameCollision.js
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPatternNameCollision.js
@@ -6,7 +6,7 @@ function /*[#|*/f/*|]*/() {
}
function res({ status, trailer }){
console.log(status);
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -17,4 +17,4 @@ async function f() {
}
function res({ status, trailer }){
console.log(status);
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPatternNameCollision.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPatternNameCollision.ts
index 6813472966a..40488dbe73c 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPatternNameCollision.ts
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_bindingPatternNameCollision.ts
@@ -6,7 +6,7 @@ function /*[#|*/f/*|]*/() {
}
function res({ status, trailer }){
console.log(status);
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -17,4 +17,4 @@ async function f() {
}
function res({ status, trailer }){
console.log(status);
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_callbackReturnsRejectedPromiseInTryBlock.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_callbackReturnsRejectedPromiseInTryBlock.js
index 2cfd6ba951e..bbbcee9d86b 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_callbackReturnsRejectedPromiseInTryBlock.js
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_callbackReturnsRejectedPromiseInTryBlock.js
@@ -4,7 +4,7 @@ function /*[#|*/f/*|]*/() {
return Promise.resolve(1)
.then(x => Promise.reject(x))
.catch(err => console.log(err));
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -16,4 +16,4 @@ async function f() {
catch (err) {
return console.log(err);
}
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_callbackReturnsRejectedPromiseInTryBlock.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_callbackReturnsRejectedPromiseInTryBlock.ts
index 2cfd6ba951e..bbbcee9d86b 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_callbackReturnsRejectedPromiseInTryBlock.ts
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_callbackReturnsRejectedPromiseInTryBlock.ts
@@ -4,7 +4,7 @@ function /*[#|*/f/*|]*/() {
return Promise.resolve(1)
.then(x => Promise.reject(x))
.catch(err => console.log(err));
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -16,4 +16,4 @@ async function f() {
catch (err) {
return console.log(err);
}
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_catchBlockUniqueParams.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_catchBlockUniqueParams.js
index 2600adec16b..fa5d3babf72 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_catchBlockUniqueParams.js
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_catchBlockUniqueParams.js
@@ -1,8 +1,8 @@
// ==ORIGINAL==
function /*[#|*/f/*|]*/() {
- return Promise.resolve().then(x => 1).catch(x => "a").then(x => !!x);
-}
+ return Promise.resolve().then(x => 1).catch(x => "a").then(x => !!x);
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -15,5 +15,5 @@ async function f() {
catch (x_1) {
x_2 = "a";
}
- return !!x_2;
-}
+ return !!x_2;
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_catchBlockUniqueParams.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_catchBlockUniqueParams.ts
index 5c4daf076a0..15ec7ce93cf 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_catchBlockUniqueParams.ts
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_catchBlockUniqueParams.ts
@@ -1,8 +1,8 @@
// ==ORIGINAL==
function /*[#|*/f/*|]*/() {
- return Promise.resolve().then(x => 1).catch(x => "a").then(x => !!x);
-}
+ return Promise.resolve().then(x => 1).catch(x => "a").then(x => !!x);
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -15,5 +15,5 @@ async function f() {
catch (x_1) {
x_2 = "a";
}
- return !!x_2;
-}
+ return !!x_2;
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_runEffectfulContinuation.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_runEffectfulContinuation.js
index 4753c67cdae..ffbf5c4e835 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_runEffectfulContinuation.js
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_runEffectfulContinuation.js
@@ -5,7 +5,7 @@ function /*[#|*/f/*|]*/() {
}
function res(result) {
return Promise.resolve().then(x => console.log(result));
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -16,4 +16,4 @@ async function f() {
}
function res(result) {
return Promise.resolve().then(x => console.log(result));
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_runEffectfulContinuation.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_runEffectfulContinuation.ts
index 4753c67cdae..ffbf5c4e835 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_runEffectfulContinuation.ts
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_runEffectfulContinuation.ts
@@ -5,7 +5,7 @@ function /*[#|*/f/*|]*/() {
}
function res(result) {
return Promise.resolve().then(x => console.log(result));
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
@@ -16,4 +16,4 @@ async function f() {
}
function res(result) {
return Promise.resolve().then(x => console.log(result));
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js
index a92497ca937..d3696bcf039 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js
@@ -2,11 +2,11 @@
const /*[#|*/foo/*|]*/ = function () {
return fetch('https://typescriptlang.org').then(result => { console.log(result) });
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
const foo = async function () {
const result = await fetch('https://typescriptlang.org');
console.log(result);
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts
index a92497ca937..d3696bcf039 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts
@@ -2,11 +2,11 @@
const /*[#|*/foo/*|]*/ = function () {
return fetch('https://typescriptlang.org').then(result => { console.log(result) });
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
const foo = async function () {
const result = await fetch('https://typescriptlang.org');
console.log(result);
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.js
index b34c369046f..9f108e9e2a4 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.js
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.js
@@ -2,11 +2,11 @@
const { length } = /*[#|*/function/*|]*/ () {
return fetch('https://typescriptlang.org').then(result => { console.log(result) });
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
const { length } = async function () {
const result = await fetch('https://typescriptlang.org');
console.log(result);
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.ts
index b34c369046f..9f108e9e2a4 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.ts
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionAssignedToBindingPattern.ts
@@ -2,11 +2,11 @@
const { length } = /*[#|*/function/*|]*/ () {
return fetch('https://typescriptlang.org').then(result => { console.log(result) });
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
const { length } = async function () {
const result = await fetch('https://typescriptlang.org');
console.log(result);
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionWithName.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionWithName.js
index 8316ee98b5b..155f28eae83 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionWithName.js
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionWithName.js
@@ -2,11 +2,11 @@
const foo = function /*[#|*/f/*|]*/() {
return fetch('https://typescriptlang.org').then(result => { console.log(result) });
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
const foo = async function f() {
const result = await fetch('https://typescriptlang.org');
console.log(result);
-}
+}
diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionWithName.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionWithName.ts
index 8316ee98b5b..155f28eae83 100644
--- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionWithName.ts
+++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpressionWithName.ts
@@ -2,11 +2,11 @@
const foo = function /*[#|*/f/*|]*/() {
return fetch('https://typescriptlang.org').then(result => { console.log(result) });
-}
+}
// ==ASYNC FUNCTION::Convert to async function==
const foo = async function f() {
const result = await fetch('https://typescriptlang.org');
console.log(result);
-}
+}
diff --git a/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js
new file mode 100644
index 00000000000..7191d615fc6
--- /dev/null
+++ b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js
@@ -0,0 +1,7 @@
+// [source.js.map]
+{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts","another.html"],"names":[],"mappings":"AAAA,iCACyB,CAAA;ACDzB,QAAS,CDED"}
+
+// [source.js]
+"multi\n line";
+'change';
+//# sourceMappingURL=source.js.map
\ No newline at end of file
diff --git a/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js
new file mode 100644
index 00000000000..4845bc413c4
--- /dev/null
+++ b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js
@@ -0,0 +1,54 @@
+//// [declarationEmitLocalClassHasRequiredDeclare.ts]
+export declare namespace A {
+ namespace X { }
+}
+
+class X { }
+
+export class A {
+ static X = X;
+}
+
+export declare namespace Y {
+
+}
+
+export class Y { }
+
+//// [declarationEmitLocalClassHasRequiredDeclare.js]
+"use strict";
+exports.__esModule = true;
+var X = /** @class */ (function () {
+ function X() {
+ }
+ return X;
+}());
+var A = /** @class */ (function () {
+ function A() {
+ }
+ A.X = X;
+ return A;
+}());
+exports.A = A;
+var Y = /** @class */ (function () {
+ function Y() {
+ }
+ return Y;
+}());
+exports.Y = Y;
+
+
+//// [declarationEmitLocalClassHasRequiredDeclare.d.ts]
+export declare namespace A {
+ namespace X { }
+}
+declare class X {
+}
+export declare class A {
+ static X: typeof X;
+}
+export declare namespace Y {
+}
+export declare class Y {
+}
+export {};
diff --git a/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.symbols b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.symbols
new file mode 100644
index 00000000000..27cb72b00e0
--- /dev/null
+++ b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.symbols
@@ -0,0 +1,27 @@
+=== tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts ===
+export declare namespace A {
+>A : Symbol(A, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 0, 0), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 4, 11))
+
+ namespace X { }
+>X : Symbol(X, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 0, 28), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 6, 16))
+}
+
+class X { }
+>X : Symbol(X, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 2, 1))
+
+export class A {
+>A : Symbol(A, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 0, 0), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 4, 11))
+
+ static X = X;
+>X : Symbol(A.X, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 0, 28), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 6, 16))
+>X : Symbol(X, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 2, 1))
+}
+
+export declare namespace Y {
+>Y : Symbol(Y, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 8, 1), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 12, 1))
+
+}
+
+export class Y { }
+>Y : Symbol(Y, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 8, 1), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 12, 1))
+
diff --git a/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.types b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.types
new file mode 100644
index 00000000000..130f87cd013
--- /dev/null
+++ b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.types
@@ -0,0 +1,23 @@
+=== tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts ===
+export declare namespace A {
+ namespace X { }
+}
+
+class X { }
+>X : X
+
+export class A {
+>A : A
+
+ static X = X;
+>X : typeof X
+>X : typeof X
+}
+
+export declare namespace Y {
+
+}
+
+export class Y { }
+>Y : Y
+
diff --git a/tests/baselines/reference/decoratorWithNegativeLiteralTypeNoCrash.js b/tests/baselines/reference/decoratorWithNegativeLiteralTypeNoCrash.js
new file mode 100644
index 00000000000..57b548cdf99
--- /dev/null
+++ b/tests/baselines/reference/decoratorWithNegativeLiteralTypeNoCrash.js
@@ -0,0 +1,28 @@
+//// [decoratorWithNegativeLiteralTypeNoCrash.ts]
+class A {
+ @decorator
+ public field1: -1 = -1;
+}
+function decorator(target: any, field: any) {}
+
+//// [decoratorWithNegativeLiteralTypeNoCrash.js]
+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 __metadata = (this && this.__metadata) || function (k, v) {
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
+};
+var A = /** @class */ (function () {
+ function A() {
+ this.field1 = -1;
+ }
+ __decorate([
+ decorator,
+ __metadata("design:type", Number)
+ ], A.prototype, "field1", void 0);
+ return A;
+}());
+function decorator(target, field) { }
diff --git a/tests/baselines/reference/decoratorWithNegativeLiteralTypeNoCrash.symbols b/tests/baselines/reference/decoratorWithNegativeLiteralTypeNoCrash.symbols
new file mode 100644
index 00000000000..e89854249a0
--- /dev/null
+++ b/tests/baselines/reference/decoratorWithNegativeLiteralTypeNoCrash.symbols
@@ -0,0 +1,15 @@
+=== tests/cases/compiler/decoratorWithNegativeLiteralTypeNoCrash.ts ===
+class A {
+>A : Symbol(A, Decl(decoratorWithNegativeLiteralTypeNoCrash.ts, 0, 0))
+
+ @decorator
+>decorator : Symbol(decorator, Decl(decoratorWithNegativeLiteralTypeNoCrash.ts, 3, 1))
+
+ public field1: -1 = -1;
+>field1 : Symbol(A.field1, Decl(decoratorWithNegativeLiteralTypeNoCrash.ts, 0, 9))
+}
+function decorator(target: any, field: any) {}
+>decorator : Symbol(decorator, Decl(decoratorWithNegativeLiteralTypeNoCrash.ts, 3, 1))
+>target : Symbol(target, Decl(decoratorWithNegativeLiteralTypeNoCrash.ts, 4, 19))
+>field : Symbol(field, Decl(decoratorWithNegativeLiteralTypeNoCrash.ts, 4, 31))
+
diff --git a/tests/baselines/reference/decoratorWithNegativeLiteralTypeNoCrash.types b/tests/baselines/reference/decoratorWithNegativeLiteralTypeNoCrash.types
new file mode 100644
index 00000000000..45f4ff03451
--- /dev/null
+++ b/tests/baselines/reference/decoratorWithNegativeLiteralTypeNoCrash.types
@@ -0,0 +1,19 @@
+=== tests/cases/compiler/decoratorWithNegativeLiteralTypeNoCrash.ts ===
+class A {
+>A : A
+
+ @decorator
+>decorator : (target: any, field: any) => void
+
+ public field1: -1 = -1;
+>field1 : -1
+>-1 : -1
+>1 : 1
+>-1 : -1
+>1 : 1
+}
+function decorator(target: any, field: any) {}
+>decorator : (target: any, field: any) => void
+>target : any
+>field : any
+
diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types
index 389b6b5e5f5..0fb81ba6aa3 100644
--- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types
+++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types
@@ -45,8 +45,8 @@ const [f, g = f, h = i, i = f] = [1]; // error for h = i
>c : number
>d : number
>c : number
->e : number
->e : number
+>e : any
+>e : any
})([1]);
>[1] : number[]
diff --git a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.js b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.js
index 2dd6b4ea11a..1215d343df0 100644
--- a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.js
+++ b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.js
@@ -17,9 +17,16 @@ const Child: SFC = ({
children,
name = "Artemis",
...props
-}) => `name: ${name} props: ${JSON.stringify(props)}`;
+}) => `name: ${name} props: ${JSON.stringify(props)}`;
+
+// Repro from #29189
+
+declare function f(g: (as: string[]) => void): void
+f(([_1, _2 = undefined]) => undefined)
+
//// [destructuringInitializerContextualTypeFromContext.js]
+"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -48,3 +55,7 @@ var Child = function (_a) {
var children = _a.children, _b = _a.name, name = _b === void 0 ? "Artemis" : _b, props = __rest(_a, ["children", "name"]);
return "name: " + name + " props: " + JSON.stringify(props);
};
+f(function (_a) {
+ var _1 = _a[0], _b = _a[1], _2 = _b === void 0 ? undefined : _b;
+ return undefined;
+});
diff --git a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.symbols b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.symbols
index 317a09ee105..8ae1b56e20f 100644
--- a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.symbols
+++ b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.symbols
@@ -56,3 +56,17 @@ const Child: SFC = ({
>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>props : Symbol(props, Decl(destructuringInitializerContextualTypeFromContext.ts, 16, 21))
+// Repro from #29189
+
+declare function f(g: (as: string[]) => void): void
+>f : Symbol(f, Decl(destructuringInitializerContextualTypeFromContext.ts, 18, 54))
+>g : Symbol(g, Decl(destructuringInitializerContextualTypeFromContext.ts, 22, 19))
+>as : Symbol(as, Decl(destructuringInitializerContextualTypeFromContext.ts, 22, 23))
+
+f(([_1, _2 = undefined]) => undefined)
+>f : Symbol(f, Decl(destructuringInitializerContextualTypeFromContext.ts, 18, 54))
+>_1 : Symbol(_1, Decl(destructuringInitializerContextualTypeFromContext.ts, 23, 4))
+>_2 : Symbol(_2, Decl(destructuringInitializerContextualTypeFromContext.ts, 23, 7))
+>undefined : Symbol(undefined)
+>undefined : Symbol(undefined)
+
diff --git a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.types b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.types
index fa76e2eef25..4018d4bed3f 100644
--- a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.types
+++ b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.types
@@ -50,8 +50,24 @@ const Child: SFC = ({
>`name: ${name} props: ${JSON.stringify(props)}` : string
>name : "Apollo" | "Artemis" | "Dionysus" | "Persephone"
>JSON.stringify(props) : string
->JSON.stringify : { (value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; }
+>JSON.stringify : { (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; }
>JSON : JSON
->stringify : { (value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; }
+>stringify : { (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; }
>props : {}
+// Repro from #29189
+
+declare function f(g: (as: string[]) => void): void
+>f : (g: (as: string[]) => void) => void
+>g : (as: string[]) => void
+>as : string[]
+
+f(([_1, _2 = undefined]) => undefined)
+>f(([_1, _2 = undefined]) => undefined) : void
+>f : (g: (as: string[]) => void) => void
+>([_1, _2 = undefined]) => undefined : ([_1, _2]: string[]) => undefined
+>_1 : string
+>_2 : string | undefined
+>undefined : undefined
+>undefined : undefined
+
diff --git a/tests/baselines/reference/discriminantPropertyCheck.errors.txt b/tests/baselines/reference/discriminantPropertyCheck.errors.txt
index a57e17ed81e..313116edde5 100644
--- a/tests/baselines/reference/discriminantPropertyCheck.errors.txt
+++ b/tests/baselines/reference/discriminantPropertyCheck.errors.txt
@@ -106,4 +106,26 @@ tests/cases/compiler/discriminantPropertyCheck.ts(65,9): error TS2532: Object is
}
}
}
+
+ // Repro from #29106
+
+ const f = (_a: string, _b: string): void => {};
+
+ interface A {
+ a?: string;
+ b?: string;
+ }
+
+ interface B {
+ a: string;
+ b: string;
+ }
+
+ type U = A | B;
+
+ const u: U = {} as any;
+
+ u.a && u.b && f(u.a, u.b);
+
+ u.b && u.a && f(u.a, u.b);
\ No newline at end of file
diff --git a/tests/baselines/reference/discriminantPropertyCheck.js b/tests/baselines/reference/discriminantPropertyCheck.js
index e58f28dc5a1..8b2c6f122bc 100644
--- a/tests/baselines/reference/discriminantPropertyCheck.js
+++ b/tests/baselines/reference/discriminantPropertyCheck.js
@@ -98,6 +98,28 @@ function func2(inst: Instance) {
}
}
}
+
+// Repro from #29106
+
+const f = (_a: string, _b: string): void => {};
+
+interface A {
+ a?: string;
+ b?: string;
+}
+
+interface B {
+ a: string;
+ b: string;
+}
+
+type U = A | B;
+
+const u: U = {} as any;
+
+u.a && u.b && f(u.a, u.b);
+
+u.b && u.a && f(u.a, u.b);
//// [discriminantPropertyCheck.js]
@@ -161,3 +183,8 @@ function func2(inst) {
}
}
}
+// Repro from #29106
+var f = function (_a, _b) { };
+var u = {};
+u.a && u.b && f(u.a, u.b);
+u.b && u.a && f(u.a, u.b);
diff --git a/tests/baselines/reference/discriminantPropertyCheck.symbols b/tests/baselines/reference/discriminantPropertyCheck.symbols
index 564cc55e3d3..78884eaf69f 100644
--- a/tests/baselines/reference/discriminantPropertyCheck.symbols
+++ b/tests/baselines/reference/discriminantPropertyCheck.symbols
@@ -311,3 +311,69 @@ function func2(inst: Instance) {
}
}
+// Repro from #29106
+
+const f = (_a: string, _b: string): void => {};
+>f : Symbol(f, Decl(discriminantPropertyCheck.ts, 102, 5))
+>_a : Symbol(_a, Decl(discriminantPropertyCheck.ts, 102, 11))
+>_b : Symbol(_b, Decl(discriminantPropertyCheck.ts, 102, 22))
+
+interface A {
+>A : Symbol(A, Decl(discriminantPropertyCheck.ts, 102, 47))
+
+ a?: string;
+>a : Symbol(A.a, Decl(discriminantPropertyCheck.ts, 104, 13))
+
+ b?: string;
+>b : Symbol(A.b, Decl(discriminantPropertyCheck.ts, 105, 13))
+}
+
+interface B {
+>B : Symbol(B, Decl(discriminantPropertyCheck.ts, 107, 1))
+
+ a: string;
+>a : Symbol(B.a, Decl(discriminantPropertyCheck.ts, 109, 13))
+
+ b: string;
+>b : Symbol(B.b, Decl(discriminantPropertyCheck.ts, 110, 12))
+}
+
+type U = A | B;
+>U : Symbol(U, Decl(discriminantPropertyCheck.ts, 112, 1))
+>A : Symbol(A, Decl(discriminantPropertyCheck.ts, 102, 47))
+>B : Symbol(B, Decl(discriminantPropertyCheck.ts, 107, 1))
+
+const u: U = {} as any;
+>u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5))
+>U : Symbol(U, Decl(discriminantPropertyCheck.ts, 112, 1))
+
+u.a && u.b && f(u.a, u.b);
+>u.a : Symbol(a, Decl(discriminantPropertyCheck.ts, 104, 13), Decl(discriminantPropertyCheck.ts, 109, 13))
+>u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5))
+>a : Symbol(a, Decl(discriminantPropertyCheck.ts, 104, 13), Decl(discriminantPropertyCheck.ts, 109, 13))
+>u.b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12))
+>u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5))
+>b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12))
+>f : Symbol(f, Decl(discriminantPropertyCheck.ts, 102, 5))
+>u.a : Symbol(a, Decl(discriminantPropertyCheck.ts, 104, 13), Decl(discriminantPropertyCheck.ts, 109, 13))
+>u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5))
+>a : Symbol(a, Decl(discriminantPropertyCheck.ts, 104, 13), Decl(discriminantPropertyCheck.ts, 109, 13))
+>u.b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12))
+>u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5))
+>b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12))
+
+u.b && u.a && f(u.a, u.b);
+>u.b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12))
+>u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5))
+>b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12))
+>u.a : Symbol(a, Decl(discriminantPropertyCheck.ts, 104, 13), Decl(discriminantPropertyCheck.ts, 109, 13))
+>u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5))
+>a : Symbol(a, Decl(discriminantPropertyCheck.ts, 104, 13), Decl(discriminantPropertyCheck.ts, 109, 13))
+>f : Symbol(f, Decl(discriminantPropertyCheck.ts, 102, 5))
+>u.a : Symbol(a, Decl(discriminantPropertyCheck.ts, 104, 13), Decl(discriminantPropertyCheck.ts, 109, 13))
+>u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5))
+>a : Symbol(a, Decl(discriminantPropertyCheck.ts, 104, 13), Decl(discriminantPropertyCheck.ts, 109, 13))
+>u.b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12))
+>u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5))
+>b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12))
+
diff --git a/tests/baselines/reference/discriminantPropertyCheck.types b/tests/baselines/reference/discriminantPropertyCheck.types
index 4f34ceafc43..c243ef5e798 100644
--- a/tests/baselines/reference/discriminantPropertyCheck.types
+++ b/tests/baselines/reference/discriminantPropertyCheck.types
@@ -310,3 +310,71 @@ function func2(inst: Instance) {
}
}
+// Repro from #29106
+
+const f = (_a: string, _b: string): void => {};
+>f : (_a: string, _b: string) => void
+>(_a: string, _b: string): void => {} : (_a: string, _b: string) => void
+>_a : string
+>_b : string
+
+interface A {
+ a?: string;
+>a : string | undefined
+
+ b?: string;
+>b : string | undefined
+}
+
+interface B {
+ a: string;
+>a : string
+
+ b: string;
+>b : string
+}
+
+type U = A | B;
+>U : U
+
+const u: U = {} as any;
+>u : U
+>{} as any : any
+>{} : {}
+
+u.a && u.b && f(u.a, u.b);
+>u.a && u.b && f(u.a, u.b) : void | "" | undefined
+>u.a && u.b : string | undefined
+>u.a : string | undefined
+>u : U
+>a : string | undefined
+>u.b : string | undefined
+>u : U
+>b : string | undefined
+>f(u.a, u.b) : void
+>f : (_a: string, _b: string) => void
+>u.a : string
+>u : U
+>a : string
+>u.b : string
+>u : U
+>b : string
+
+u.b && u.a && f(u.a, u.b);
+>u.b && u.a && f(u.a, u.b) : void | "" | undefined
+>u.b && u.a : string | undefined
+>u.b : string | undefined
+>u : U
+>b : string | undefined
+>u.a : string | undefined
+>u : U
+>a : string | undefined
+>f(u.a, u.b) : void
+>f : (_a: string, _b: string) => void
+>u.a : string
+>u : U
+>a : string
+>u.b : string
+>u : U
+>b : string
+
diff --git a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt
index 4675136d081..5b8e83b3cca 100644
--- a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt
+++ b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt
@@ -11,24 +11,24 @@ tests/cases/compiler/main.ts(33,8): error TS1192: Module '"function"' has no def
tests/cases/compiler/main.ts(34,8): error TS1192: Module '"function-module"' has no default export.
tests/cases/compiler/main.ts(35,8): error TS1192: Module '"class"' has no default export.
tests/cases/compiler/main.ts(36,8): error TS1192: Module '"class-module"' has no default export.
-tests/cases/compiler/main.ts(39,21): error TS2497: Module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
-tests/cases/compiler/main.ts(45,21): error TS2497: Module '"function"' resolves to a non-module entity and cannot be imported using this construct.
-tests/cases/compiler/main.ts(47,21): error TS2497: Module '"class"' resolves to a non-module entity and cannot be imported using this construct.
+tests/cases/compiler/main.ts(39,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
+tests/cases/compiler/main.ts(45,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
+tests/cases/compiler/main.ts(47,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
tests/cases/compiler/main.ts(50,1): error TS2693: 'y1' only refers to a type, but is being used as a value here.
tests/cases/compiler/main.ts(56,4): error TS2339: Property 'a' does not exist on type '() => any'.
tests/cases/compiler/main.ts(58,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'.
tests/cases/compiler/main.ts(62,10): error TS2305: Module '"interface"' has no exported member 'a'.
-tests/cases/compiler/main.ts(62,25): error TS2497: Module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
+tests/cases/compiler/main.ts(62,25): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
tests/cases/compiler/main.ts(68,10): error TS2305: Module '"function"' has no exported member 'a'.
-tests/cases/compiler/main.ts(68,25): error TS2497: Module '"function"' resolves to a non-module entity and cannot be imported using this construct.
+tests/cases/compiler/main.ts(68,25): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
tests/cases/compiler/main.ts(70,10): error TS2305: Module '"class"' has no exported member 'a'.
-tests/cases/compiler/main.ts(70,25): error TS2497: Module '"class"' resolves to a non-module entity and cannot be imported using this construct.
+tests/cases/compiler/main.ts(70,25): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
tests/cases/compiler/main.ts(85,10): error TS2305: Module '"interface"' has no exported member 'a'.
-tests/cases/compiler/main.ts(85,25): error TS2497: Module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
+tests/cases/compiler/main.ts(85,25): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
tests/cases/compiler/main.ts(91,10): error TS2305: Module '"function"' has no exported member 'a'.
-tests/cases/compiler/main.ts(91,25): error TS2497: Module '"function"' resolves to a non-module entity and cannot be imported using this construct.
+tests/cases/compiler/main.ts(91,25): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
tests/cases/compiler/main.ts(93,10): error TS2305: Module '"class"' has no exported member 'a'.
-tests/cases/compiler/main.ts(93,25): error TS2497: Module '"class"' resolves to a non-module entity and cannot be imported using this construct.
+tests/cases/compiler/main.ts(93,25): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
tests/cases/compiler/main.ts(97,15): error TS2498: Module '"interface"' uses 'export =' and cannot be used with 'export *'.
tests/cases/compiler/main.ts(98,15): error TS2498: Module '"variable"' uses 'export =' and cannot be used with 'export *'.
tests/cases/compiler/main.ts(99,15): error TS2498: Module '"interface-variable"' uses 'export =' and cannot be used with 'export *'.
@@ -108,7 +108,7 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses
// namespace import
import * as y1 from "interface";
~~~~~~~~~~~
-!!! error TS2497: Module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
import * as y2 from "variable";
import * as y3 from "interface-variable";
import * as y4 from "module";
@@ -116,11 +116,11 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses
import * as y6 from "variable-module";
import * as y7 from "function";
~~~~~~~~~~
-!!! error TS2497: Module '"function"' resolves to a non-module entity and cannot be imported using this construct.
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
import * as y8 from "function-module";
import * as y9 from "class";
~~~~~~~
-!!! error TS2497: Module '"class"' resolves to a non-module entity and cannot be imported using this construct.
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
import * as y0 from "class-module";
y1.a;
@@ -145,7 +145,7 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses
~
!!! error TS2305: Module '"interface"' has no exported member 'a'.
~~~~~~~~~~~
-!!! error TS2497: Module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
import { a as a2 } from "variable";
import { a as a3 } from "interface-variable";
import { a as a4 } from "module";
@@ -155,13 +155,13 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses
~
!!! error TS2305: Module '"function"' has no exported member 'a'.
~~~~~~~~~~
-!!! error TS2497: Module '"function"' resolves to a non-module entity and cannot be imported using this construct.
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
import { a as a8 } from "function-module";
import { a as a9 } from "class";
~
!!! error TS2305: Module '"class"' has no exported member 'a'.
~~~~~~~
-!!! error TS2497: Module '"class"' resolves to a non-module entity and cannot be imported using this construct.
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
import { a as a0 } from "class-module";
a1;
@@ -180,7 +180,7 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses
~
!!! error TS2305: Module '"interface"' has no exported member 'a'.
~~~~~~~~~~~
-!!! error TS2497: Module '"interface"' resolves to a non-module entity and cannot be imported using this construct.
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
export { a as a2 } from "variable";
export { a as a3 } from "interface-variable";
export { a as a4 } from "module";
@@ -190,13 +190,13 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses
~
!!! error TS2305: Module '"function"' has no exported member 'a'.
~~~~~~~~~~
-!!! error TS2497: Module '"function"' resolves to a non-module entity and cannot be imported using this construct.
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
export { a as a8 } from "function-module";
export { a as a9 } from "class";
~
!!! error TS2305: Module '"class"' has no exported member 'a'.
~~~~~~~
-!!! error TS2497: Module '"class"' resolves to a non-module entity and cannot be imported using this construct.
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
export { a as a0 } from "class-module";
// export-star
diff --git a/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.errors.txt b/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.errors.txt
new file mode 100644
index 00000000000..3d8301d3ca1
--- /dev/null
+++ b/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.errors.txt
@@ -0,0 +1,15 @@
+tests/cases/compiler/main.ts(1,20): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
+
+
+==== tests/cases/compiler/a.ts (0 errors) ====
+ class a { }
+ export = a;
+
+==== tests/cases/compiler/main.ts (1 errors) ====
+ import * as a from "./a";
+ ~~~~~
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
+ a;
+
+
+
\ No newline at end of file
diff --git a/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.js b/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.js
new file mode 100644
index 00000000000..37f127721ce
--- /dev/null
+++ b/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.js
@@ -0,0 +1,26 @@
+//// [tests/cases/compiler/es6ImportEqualsExportModuleCommonJsError.ts] ////
+
+//// [a.ts]
+class a { }
+export = a;
+
+//// [main.ts]
+import * as a from "./a";
+a;
+
+
+
+
+//// [a.js]
+"use strict";
+var a = /** @class */ (function () {
+ function a() {
+ }
+ return a;
+}());
+module.exports = a;
+//// [main.js]
+"use strict";
+exports.__esModule = true;
+var a = require("./a");
+a;
diff --git a/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.symbols b/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.symbols
new file mode 100644
index 00000000000..071f2fb5725
--- /dev/null
+++ b/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.symbols
@@ -0,0 +1,16 @@
+=== tests/cases/compiler/a.ts ===
+class a { }
+>a : Symbol(a, Decl(a.ts, 0, 0))
+
+export = a;
+>a : Symbol(a, Decl(a.ts, 0, 0))
+
+=== tests/cases/compiler/main.ts ===
+import * as a from "./a";
+>a : Symbol(a, Decl(main.ts, 0, 6))
+
+a;
+>a : Symbol(a, Decl(main.ts, 0, 6))
+
+
+
diff --git a/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.types b/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.types
new file mode 100644
index 00000000000..652d7d6241b
--- /dev/null
+++ b/tests/baselines/reference/es6ImportEqualsExportModuleCommonJsError.types
@@ -0,0 +1,16 @@
+=== tests/cases/compiler/a.ts ===
+class a { }
+>a : a
+
+export = a;
+>a : a
+
+=== tests/cases/compiler/main.ts ===
+import * as a from "./a";
+>a : typeof a
+
+a;
+>a : typeof a
+
+
+
diff --git a/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.errors.txt b/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.errors.txt
new file mode 100644
index 00000000000..94c05e068f5
--- /dev/null
+++ b/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.errors.txt
@@ -0,0 +1,18 @@
+tests/cases/compiler/a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+tests/cases/compiler/main.ts(1,20): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export.
+
+
+==== tests/cases/compiler/a.ts (1 errors) ====
+ class a { }
+ export = a;
+ ~~~~~~~~~~~
+!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
+
+==== tests/cases/compiler/main.ts (1 errors) ====
+ import * as a from "./a";
+ ~~~~~
+!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export.
+ a;
+
+
+
\ No newline at end of file
diff --git a/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.js b/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.js
new file mode 100644
index 00000000000..603f158946e
--- /dev/null
+++ b/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.js
@@ -0,0 +1,22 @@
+//// [tests/cases/compiler/es6ImportEqualsExportModuleEs2015Error.ts] ////
+
+//// [a.ts]
+class a { }
+export = a;
+
+//// [main.ts]
+import * as a from "./a";
+a;
+
+
+
+
+//// [a.js]
+var a = /** @class */ (function () {
+ function a() {
+ }
+ return a;
+}());
+//// [main.js]
+import * as a from "./a";
+a;
diff --git a/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.symbols b/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.symbols
new file mode 100644
index 00000000000..071f2fb5725
--- /dev/null
+++ b/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.symbols
@@ -0,0 +1,16 @@
+=== tests/cases/compiler/a.ts ===
+class a { }
+>a : Symbol(a, Decl(a.ts, 0, 0))
+
+export = a;
+>a : Symbol(a, Decl(a.ts, 0, 0))
+
+=== tests/cases/compiler/main.ts ===
+import * as a from "./a";
+>a : Symbol(a, Decl(main.ts, 0, 6))
+
+a;
+>a : Symbol(a, Decl(main.ts, 0, 6))
+
+
+
diff --git a/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.types b/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.types
new file mode 100644
index 00000000000..652d7d6241b
--- /dev/null
+++ b/tests/baselines/reference/es6ImportEqualsExportModuleEs2015Error.types
@@ -0,0 +1,16 @@
+=== tests/cases/compiler/a.ts ===
+class a { }
+>a : a
+
+export = a;
+>a : a
+
+=== tests/cases/compiler/main.ts ===
+import * as a from "./a";
+>a : typeof a
+
+a;
+>a : typeof a
+
+
+
diff --git a/tests/baselines/reference/extendsJavaScript.js b/tests/baselines/reference/extendsJavaScript.js
new file mode 100644
index 00000000000..c9fbdbaf587
--- /dev/null
+++ b/tests/baselines/reference/extendsJavaScript.js
@@ -0,0 +1,18 @@
+//// [extendsJavaScript.js]
+/**
+ * @extends {SomeBase}
+ */
+class MyClass {
+
+}
+
+
+//// [extendsJavaScript.js]
+/**
+ * @extends {SomeBase}
+ */
+var MyClass = /** @class */ (function () {
+ function MyClass() {
+ }
+ return MyClass;
+}());
diff --git a/tests/baselines/reference/extendsJavaScript.symbols b/tests/baselines/reference/extendsJavaScript.symbols
new file mode 100644
index 00000000000..db070bf9d6b
--- /dev/null
+++ b/tests/baselines/reference/extendsJavaScript.symbols
@@ -0,0 +1,9 @@
+=== tests/cases/compiler/extendsJavaScript.js ===
+/**
+ * @extends {SomeBase}
+ */
+class MyClass {
+>MyClass : Symbol(MyClass, Decl(extendsJavaScript.js, 0, 0))
+
+}
+
diff --git a/tests/baselines/reference/extendsJavaScript.types b/tests/baselines/reference/extendsJavaScript.types
new file mode 100644
index 00000000000..e4d34df51aa
--- /dev/null
+++ b/tests/baselines/reference/extendsJavaScript.types
@@ -0,0 +1,9 @@
+=== tests/cases/compiler/extendsJavaScript.js ===
+/**
+ * @extends {SomeBase}
+ */
+class MyClass {
+>MyClass : MyClass
+
+}
+
diff --git a/tests/baselines/reference/genericDefaults.errors.txt b/tests/baselines/reference/genericDefaults.errors.txt
new file mode 100644
index 00000000000..0c7d9ccb21d
--- /dev/null
+++ b/tests/baselines/reference/genericDefaults.errors.txt
@@ -0,0 +1,528 @@
+tests/cases/compiler/genericDefaults.ts(44,26): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(237,26): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(254,29): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(277,26): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(292,29): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(314,26): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(332,29): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(357,26): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(375,29): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(423,19): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+tests/cases/compiler/genericDefaults.ts(427,19): error TS2744: Type parameter defaults can only reference previously declared type parameters.
+
+
+==== tests/cases/compiler/genericDefaults.ts (11 errors) ====
+ interface A { a: number; }
+ interface B { b: number; }
+ interface C { c: number; }
+ interface D { d: number; }
+ interface AB { a: number; b: number; }
+ interface BC { b: number; c: number; }
+
+ declare const a: A;
+ declare const b: B;
+ declare const c: C;
+ declare const d: D;
+ declare const ab: AB;
+ declare const bc: BC;
+ declare const x: any;
+
+ // function without type parameters
+ declare function f00(a?: A): A;
+ // no inference
+ f00();
+ f00(a);
+
+ // function with a type parameter without a default
+ declare function f01(a?: T): T;
+ // inference
+ f01();
+ f01(a);
+ // no inference, fully supplied
+ f01();
+ f01(a);
+
+ // function with a type paramter with a default
+ declare function f02(a?: T): T;
+ // inference
+ f02();
+ f02(a);
+ f02(b);
+ // no inference, fully supplied
+ f02();
+ f02(a);
+ f02();
+ f02(b);
+
+ // function with a type parameter with a default that refers to itself
+ declare function f03(a?: T): T;
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ // inference
+ f03();
+ f03(a);
+ f03(b);
+ // no inference, fully supplied
+ f03();
+ f03(a);
+ f03();
+ f03(b);
+
+ // function with a type paramter without a default and a type parameter with a default
+ declare function f04(a?: T, b?: U): [T, U];
+ // inference
+ f04();
+ f04(a);
+ f04(a, b);
+ f04(a, c);
+ // no inference, partially supplied
+ f04();
+ f04(a);
+ f04(a, b);
+ // no inference, fully supplied
+ f04();
+ f04(a);
+ f04(a, b);
+ f04();
+ f04(a);
+ f04(a, c);
+
+ // function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter
+ declare function f05(a?: T, b?: U): [T, U];
+ // inference
+ f05();
+ f05(a);
+ f05(a, a);
+ f05(a, b);
+ // no inference, partially supplied
+ f05();
+ f05(a);
+ f05(a, a);
+ // no inference, fully supplied
+ f05();
+ f05(a);
+ f05(a, b);
+
+ // function with a type parameter with a default that refers to an earlier type parameter with a default
+ declare function f06(a?: T, b?: U): [T, U];
+ // inference
+ f06();
+ f06(a);
+ f06(a, a);
+ f06(a, b);
+ f06(b, a);
+ f06(b, b);
+ // no inference, partially supplied
+ f06();
+ f06(a);
+ f06(a, a);
+ f06();
+ f06(b);
+ f06(b, b);
+ // no inference, fully supplied
+ f06();
+ f06(a);
+ f06(a, b);
+ f06();
+ f06(b);
+ f06(b, c);
+
+ // function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter with a default
+ declare function f07(a?: T, b?: U, c?: V): [T, U, V];
+ // inference
+ f07();
+ f07(a, b);
+ f07(a, c);
+ f07(a, b, b);
+ f07(a, b, c);
+ f07(a, c, b);
+ f07(a, c, c);
+ // no inference, partially supplied
+ f07();
+ f07(a);
+ f07(a, b);
+ f07(a, b, b);
+ f07();
+ f07(a);
+ f07(a, b);
+ f07(a, b, b);
+ f07();
+ f07(a);
+ f07(a, c);
+ f07(a, c, c);
+ // no inference, fully supplied
+ f07();
+ f07(a);
+ f07(a, b);
+ f07(a, b, c);
+ f07();
+ f07(a);
+ f07(a, c);
+ f07(a, c, d);
+
+ // function with a type parameter with a default that refers to an earlier type parameter with a constraint
+ declare function f08(a?: T, b?: U): [T, U];
+ // inference
+ f08();
+ f08(a);
+ f08(a, a);
+ f08(a, b);
+ // no inference, partially supplied
+ f08();
+ f08(a);
+ f08(a, a);
+ // no inference, fully supplied
+ f08();
+ f08(a);
+ f08(a, b);
+
+ // function with a type parameter with a constraint and a default that refers to an earlier type parameter
+ declare function f09(a?: T, b?: U): [T, U];
+ // inference
+ f09();
+ f09(a);
+ f09(a, a);
+ f09(a, ab);
+ // no inference, partially supplied
+ f09();
+ f09(a);
+ f09(a, a);
+ f09(a, ab);
+ // no inference, fully supplied
+ f09();
+ f09(a);
+ f09(a, ab);
+
+ // function with a type parameter with a constraint and a default that refers to an earlier type parameter with a constraint
+ declare function f10(a?: T, b?: U): [T, U];
+ // inference
+ f10();
+ f10(a);
+ f10(a, a);
+ f10(a, ab);
+ // no inference, partially supplied
+ f10();
+ f10(a);
+ f10(a, a);
+ f10(a, ab);
+ // no inference, fully supplied
+ f10();
+ f10(a);
+ f10(a, a);
+ f10(a, ab);
+ f10();
+ f10(a);
+ f10(a, ab);
+
+ // function with a type parameter with a default that refers to an earier type parameter in a union
+ declare function f11(a?: T, b?: U): [T, U];
+ // inference
+ f11();
+ f11(a);
+ f11(a, a);
+ f11(a, b);
+ f11(a, c);
+ // no inference, partially supplied
+ f11();
+ f11(a);
+ f11(a, a);
+ f11(a, b);
+ // no inference, fully supplied
+ f11();
+ f11(a);
+ f11(a, c);
+
+ // function with a type parameter with a default that refers to an earlier type parameter in an intersection
+ declare function f12(a?: T, b?: U): [T, U];
+ // inference
+ f12();
+ f12(a);
+ f12(a, a);
+ f12(a, b);
+ f12(a, c);
+ // no inference, partially supplied
+ f12();
+ f12(a);
+ f12(a, ab);
+ // no inference, fully supplied
+ f12();
+ f12(a);
+ f12(a, c);
+
+ // function with a type parameter with a default that refers to a later type parameter with a default
+ declare function f13(a?: T, b?: U): [T, U];
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ // inference
+ f13();
+ f13(a);
+ f13(a, b);
+ f13(a, c);
+ // no inference, partially supplied
+ f13();
+ f13(a);
+ f13(a, b);
+ // no inference, fully supplied
+ f13();
+ f13(a);
+ f13(a, c);
+ f13(a, c);
+
+ // function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default
+ declare function f14(a?: T, b?: U, c?: V): [T, U, V];
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ // inference
+ f14();
+ f14(a);
+ f14(a, b);
+ f14(a, b, c);
+ f14(a, b, d);
+ // no inference, partially supplied
+ f14();
+ f14(a);
+ f14(a, b);
+ f14(a, b, c);
+ f14();
+ f14(a);
+ f14(a, b);
+ f14(a, b, c);
+ // no inference fully supplied
+ f14();
+ f14(a);
+ f14(a, b);
+ f14(a, b, d);
+
+ // function with two type parameters with defaults that mutually refer to each other
+ declare function f15(a?: T, b?: U): [T, U];
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ // inference
+ f15();
+ f15(a);
+ f15(a, b);
+ // no inference, partially supplied
+ f15();
+ f15(a);
+ f15(a, a);
+ // no inference, fully supplied
+ f15();
+ f15(a);
+ f15(a, b);
+
+ // function with a type parameter without a default and two type parameters with defaults that mutually refer to each other
+ declare function f16(a?: T, b?: U, c?: V): [T, U, V];
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ // no inference
+ f16();
+ f16(a);
+ f16(a, b);
+ f16(a, b, b);
+ // no inference, partially supplied
+ f16();
+ f16(a);
+ f16(a, b);
+ f16(a, b, b);
+ f16();
+ f16(a);
+ f16(a, b);
+ f16(a, b, b);
+ // no inference, fully supplied
+ f16();
+ f16(a);
+ f16(a, b);
+ f16(a, b, d);
+
+ // function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union
+ declare function f17(a?: T, b?: U): [T, U];
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ // inference
+ f17();
+ f17(a);
+ f17(a, a);
+ f17(a, b);
+ f17(a, c);
+ // no inference, partially supplied
+ f17();
+ f17(a);
+ f17(a, a);
+ f17(a, b);
+ // no inference, fully supplied
+ f17();
+ f17(a);
+ f17(a, c);
+
+ // function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union
+ declare function f18(a?: T, b?: U, c?: V): [T, U, V];
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ // inference
+ f18();
+ f18(a);
+ f18(a, b);
+ f18(a, b, b);
+ f18(a, b, c);
+ // no inference, partially supplied
+ f18();
+ f18(a);
+ f18(a, b);
+ f18(a, b, b);
+ f18(a, b, c);
+ f18();
+ f18(a);
+ f18(a, b);
+ f18(a, b, b);
+ f18(a, b, c);
+ // no inference, fully supplied
+ f18();
+ f18(a);
+ f18(a, b);
+ f18(a, b, d);
+
+ // function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection
+ declare function f19(a?: T, b?: U): [T, U];
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ // inference
+ f19();
+ f19(a);
+ f19(a, a);
+ f19(a, b);
+ f19(a, ab);
+ f19(a, c);
+ // no inference, partially supplied
+ f19();
+ f19(a);
+ f19(a, ab);
+ // no inference, fully supplied
+ f19();
+ f19(a);
+ f19(a, c);
+
+ // function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection
+ declare function f20(a?: T, b?: U, c?: V): [T, U, V];
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ // inference
+ f20();
+ f20(a);
+ f20(a, b);
+ f20(a, b, c);
+ // no inference, partially supplied
+ f20();
+ f20(a);
+ f20(a, b);
+ f20(a, b, bc);
+ f20();
+ f20(a);
+ f20(a, b);
+ f20(a, b, bc);
+ // no inference, fully supplied
+ f20();
+ f20(a);
+ f20(a, b);
+ f20(a, b, d);
+
+ interface i00 { a: T; }
+ const i00c00 = (x).a;
+ const i00c01 = (>x).a;
+
+ interface i01 { a: [T, U]; }
+ const i01c00 = (>x).a;
+ const i01c01 = (>x).a;
+
+ interface i02 { a: [T, U]; }
+ const i02c00 = (>x).a;
+ const i02c01 = (>x).a;
+ const i02c02 = (>x).a;
+ const i02c03 = (>x).a;
+ const i02c04 = (>x).a;
+
+ interface i03 { a: [T, U]; }
+ const i03c00 = (>x).a;
+ const i03c01 = (>x).a;
+ const i03c02 = (>x).a;
+ const i03c03 = (>x).a;
+ const i03c04 = (>x).a;
+
+ interface i04 {}
+ interface i04 {}
+ interface i04 {}
+ interface i04 {}
+
+ interface i05 { a: T; }
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ const i05c00 = (x).a;
+ const i05c01 = (>x).a;
+
+ interface i06 { a: [T, U]; }
+ ~
+!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
+ const i06c00 = (x).a;
+ const i06c01 = (>x).a;
+ const i06c02 = (>x).a;
+
+ interface i07 { a: A; }
+ interface i07 { b: A; }
+ const i07c00 = (x).a;
+ const i07c01 = (x).b;
+ const i07c02 = (>x).a;
+ const i07c03 = (>x).b;
+
+ interface Base01 { a: T; }
+ interface Base01Constructor { new (a?: T): Base01; }
+
+ declare const Base01: Base01Constructor;
+ const Base01c00 = new Base01();
+ const Base01c01 = new Base01(1);
+ const Base01c02 = new Base01();
+ const Base01c03 = new Base01(1);
+
+ declare class Derived01 extends Base01 { }
+ const Derived01c00 = new Derived01();
+ const Derived01c01 = new Derived01(1);
+ const Derived01c02 = new Derived01();
+ const Derived01c03 = new Derived01(1);
+
+ declare class Derived02 extends Base01 { }
+ const Derived02c00 = new Derived02();
+ const Derived02c01 = new Derived02(1);
+ const Derived02c02 = new Derived02