diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6cc13548d11f1..5bb4e08876111 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23000,6 +23000,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return reduceLeft(types, (s, t) => isTypeSubtypeOf(t, s) ? t : s)!; } + function isPromiseType(type: Type): type is TypeReference { + return !!(getObjectFlags(type) & ObjectFlags.Reference) && ((type as TypeReference).target === getGlobalPromiseType(/*reportErrors*/ false)); + } + function isArrayType(type: Type): type is TypeReference { return !!(getObjectFlags(type) & ObjectFlags.Reference) && ((type as TypeReference).target === globalArrayType || (type as TypeReference).target === globalReadonlyArrayType); } @@ -40818,7 +40822,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkExpression(node.expression); + const exprType = checkExpression(node.expression); + if (!isAssignmentExpression(node.expression, /*excludeCompoundAssignment*/ true) && isPromiseType(exprType)) { + error(node.expression, Diagnostics.A_Promise_must_be_awaited_returned_or_explicitly_ignored_with_the_void_operator); + } } function checkIfStatement(node: IfStatement) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f3c9c5d11cdf6..a1caac260ebb5 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -6427,6 +6427,10 @@ "category": "Error", "code": 7061 }, + "A Promise must be awaited, returned, or explicitly ignored with the 'void' operator": { + "category": "Error", + "code": 7062 + }, "You cannot rename this element.": { "category": "Error", diff --git a/src/server/session.ts b/src/server/session.ts index f7e37522a8719..9d281adb92de3 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -2790,7 +2790,7 @@ export class Session implements EventSender { const commands = args.command as CodeActionCommand | CodeActionCommand[]; // They should be sending back the command we sent them. for (const command of toArray(commands)) { const { file, project } = this.getFileAndProject(command); - project.getLanguageService().applyCodeActionCommand(command, this.getFormatOptions(file)).then( + void project.getLanguageService().applyCodeActionCommand(command, this.getFormatOptions(file)).then( _result => { /* TODO: GH#20447 report success message? */ }, _error => { /* TODO: GH#20447 report errors */ }); } diff --git a/tests/baselines/reference/asyncAwaitNestedClasses_es5.errors.txt b/tests/baselines/reference/asyncAwaitNestedClasses_es5.errors.txt new file mode 100644 index 0000000000000..2e10696dc764c --- /dev/null +++ b/tests/baselines/reference/asyncAwaitNestedClasses_es5.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/async/es5/asyncAwaitNestedClasses_es5.ts(15,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/async/es5/asyncAwaitNestedClasses_es5.ts (1 errors) ==== + // https://github.com/Microsoft/TypeScript/issues/20744 + class A { + static B = class B { + static func2(): Promise { + return new Promise((resolve) => { resolve(null); }); + } + static C = class C { + static async func() { + await B.func2(); + } + } + } + } + + A.B.C.func(); + ~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/asyncIIFE.errors.txt b/tests/baselines/reference/asyncIIFE.errors.txt new file mode 100644 index 0000000000000..f71ddb85668c7 --- /dev/null +++ b/tests/baselines/reference/asyncIIFE.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/asyncIIFE.ts(2,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/asyncIIFE.ts (1 errors) ==== + function f1() { + (async () => { + ~~~~~~~~~~~~~~ + await 10 + ~~~~~~~~~~~~~~~~ + throw new Error(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + })(); + ~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + var x = 1; + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncImportNestedYield.errors.txt b/tests/baselines/reference/asyncImportNestedYield.errors.txt new file mode 100644 index 0000000000000..869bd2edc79b8 --- /dev/null +++ b/tests/baselines/reference/asyncImportNestedYield.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/asyncImportNestedYield.ts(2,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/asyncImportNestedYield.ts (1 errors) ==== + async function* foo() { + import((await import(yield "foo")).default); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } \ No newline at end of file diff --git a/tests/baselines/reference/awaitedType.errors.txt b/tests/baselines/reference/awaitedType.errors.txt index 9bee5c5dbd1c9..b9c40008e309d 100644 --- a/tests/baselines/reference/awaitedType.errors.txt +++ b/tests/baselines/reference/awaitedType.errors.txt @@ -1,9 +1,10 @@ tests/cases/compiler/awaitedType.ts(22,12): error TS2589: Type instantiation is excessively deep and possibly infinite. tests/cases/compiler/awaitedType.ts(26,12): error TS2589: Type instantiation is excessively deep and possibly infinite. +tests/cases/compiler/awaitedType.ts(234,3): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/compiler/awaitedType.ts(236,28): error TS2493: Tuple type '[number]' of length '1' has no element at index '1'. -==== tests/cases/compiler/awaitedType.ts (3 errors) ==== +==== tests/cases/compiler/awaitedType.ts (4 errors) ==== type T1 = Awaited; type T2 = Awaited>; type T3 = Awaited>; @@ -242,11 +243,16 @@ tests/cases/compiler/awaitedType.ts(236,28): error TS2493: Tuple type '[number]' const promises = [Promise.resolve(0)] as const Promise.all(promises).then((results) => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const first = results[0] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const second = results[1] // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2493: Tuple type '[number]' of length '1' has no element at index '1'. }) + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } // repro from #40330 diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt index e8a8a322903a0..2eefe14f3ea92 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt @@ -5,9 +5,11 @@ tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(100,12): error TS2448: tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(111,28): error TS2448: Block-scoped variable 'a' used before its declaration. tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(112,21): error TS2448: Block-scoped variable 'a' used before its declaration. tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(122,22): error TS2448: Block-scoped variable 'a' used before its declaration. +tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(127,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(130,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -==== tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts (7 errors) ==== +==== tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts (9 errors) ==== function foo0() { let a = x; ~ @@ -156,9 +158,13 @@ tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(122,22): error TS2448: function foo17() { const promise = (async () => { promise + ~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator foo await null promise + ~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator foo })() diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt b/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt index e2f27150dcca9..d39779c8ca2cb 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt @@ -2,6 +2,7 @@ error TS2468: Cannot find global value 'Promise'. /main.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. /main.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. /mainJs.js(2,1): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +/mainJs.js(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator !!! error TS2468: Cannot find global value 'Promise'. @@ -20,11 +21,13 @@ error TS2468: Cannot find global value 'Promise'. export = path; // ok } -==== /mainJs.js (1 errors) ==== +==== /mainJs.js (2 errors) ==== import {} from "./a"; import("./a"); ~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator const _ = require("./a"); // No resolution _.a; // any diff --git a/tests/baselines/reference/callWithSpread4.errors.txt b/tests/baselines/reference/callWithSpread4.errors.txt index d4d67faf14a23..60fc953a3998c 100644 --- a/tests/baselines/reference/callWithSpread4.errors.txt +++ b/tests/baselines/reference/callWithSpread4.errors.txt @@ -1,8 +1,10 @@ +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(16,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(18,5): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(29,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -==== tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts (2 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts (4 errors) ==== type R = { a: number } type W = { b: number } type RW = { a: number, b: number } @@ -19,15 +21,24 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): erro declare var gz: RW[] declare var fun: (inp: any) => AsyncGenerator pli( + ~~~~ reads, + ~~~~~~~~~~ ...gun, + ~~~~~~~~~~~ ~~~~~~ !!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. tr, + ~~~~~~~ fun, + ~~~~~~~~ ...gz, + ~~~~~~~~~~ writes + ~~~~~~~~~~ ); + ~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator declare function test(x: any, y: () => string): string | undefined; declare var anys: any[] @@ -36,4 +47,6 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): erro !!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. pli(...[reads, writes, writes] as const) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/controlFlowIIFE.errors.txt b/tests/baselines/reference/controlFlowIIFE.errors.txt index 50053a90f2c83..14080b1af27ad 100644 --- a/tests/baselines/reference/controlFlowIIFE.errors.txt +++ b/tests/baselines/reference/controlFlowIIFE.errors.txt @@ -1,8 +1,9 @@ tests/cases/conformance/controlFlow/controlFlowIIFE.ts(64,5): error TS2454: Variable 'v' is used before being assigned. +tests/cases/conformance/controlFlow/controlFlowIIFE.ts(69,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/controlFlow/controlFlowIIFE.ts(72,5): error TS2454: Variable 'v' is used before being assigned. -==== tests/cases/conformance/controlFlow/controlFlowIIFE.ts (2 errors) ==== +==== tests/cases/conformance/controlFlow/controlFlowIIFE.ts (3 errors) ==== declare function getStringOrNumber(): string | number; function f1() { @@ -74,8 +75,12 @@ tests/cases/conformance/controlFlow/controlFlowIIFE.ts(72,5): error TS2454: Vari function f6() { let v: number; (async function() { + ~~~~~~~~~~~~~~~~~~~ v = await 1; + ~~~~~~~~~~~~~~~~~~~~ })(); + ~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator v; // still undefined ~ !!! error TS2454: Variable 'v' is used before being assigned. diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.errors.txt b/tests/baselines/reference/defaultExportInAwaitExpression01.errors.txt new file mode 100644 index 0000000000000..822a51bfe4e99 --- /dev/null +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/es6/modules/b.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/es6/modules/a.ts (0 errors) ==== + const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); + export default x; + +==== tests/cases/conformance/es6/modules/b.ts (1 errors) ==== + import x from './a'; + + ( async function() { + ~~~~~~~~~~~~~~~~~~~~ + const value = await x; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + }() ); + ~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportInAwaitExpression02.errors.txt b/tests/baselines/reference/defaultExportInAwaitExpression02.errors.txt new file mode 100644 index 0000000000000..822a51bfe4e99 --- /dev/null +++ b/tests/baselines/reference/defaultExportInAwaitExpression02.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/es6/modules/b.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/es6/modules/a.ts (0 errors) ==== + const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); + export default x; + +==== tests/cases/conformance/es6/modules/b.ts (1 errors) ==== + import x from './a'; + + ( async function() { + ~~~~~~~~~~~~~~~~~~~~ + const value = await x; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + }() ); + ~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + \ No newline at end of file diff --git a/tests/baselines/reference/destructureOfVariableSameAsShorthand.errors.txt b/tests/baselines/reference/destructureOfVariableSameAsShorthand.errors.txt new file mode 100644 index 0000000000000..5d1ff9bde9d22 --- /dev/null +++ b/tests/baselines/reference/destructureOfVariableSameAsShorthand.errors.txt @@ -0,0 +1,40 @@ +tests/cases/compiler/destructureOfVariableSameAsShorthand.ts(10,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/compiler/destructureOfVariableSameAsShorthand.ts(14,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/destructureOfVariableSameAsShorthand.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/38969 + interface AxiosResponse { + data: T; + } + + declare function get>(): Promise; + + async function main() { + // These work examples as expected + get().then((response) => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + // body is never + ~~~~~~~~~~~~~~~~~~~~~~~~ + const body = response.data; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }) + ~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + get().then(({ data }) => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + // data is never + ~~~~~~~~~~~~~~~~~~~~~~~~ + }) + ~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + const response = await get() + // body is never + const body = response.data; + // data is never + const { data } = await get(); + + // The following did not work as expected. + // shouldBeNever should be never, but was any + const { data: shouldBeNever } = await get(); + } \ No newline at end of file diff --git a/tests/baselines/reference/dynamicImportEvaluateSpecifier.errors.txt b/tests/baselines/reference/dynamicImportEvaluateSpecifier.errors.txt new file mode 100644 index 0000000000000..414e026e2c677 --- /dev/null +++ b/tests/baselines/reference/dynamicImportEvaluateSpecifier.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/dynamicImportEvaluateSpecifier.ts(4,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/compiler/dynamicImportEvaluateSpecifier.ts(5,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/dynamicImportEvaluateSpecifier.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/48285 + let i = 0; + + import(String(i++)); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + import(String(i++)); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + const getPath = async () => { + /* in reality this would do some async FS operation, or a web request */ + return "/root/my/cool/path"; + }; + + const someFunction = async () => { + const result = await import(await getPath()); + }; + \ No newline at end of file diff --git a/tests/baselines/reference/dynamicImportTrailingComma.errors.txt b/tests/baselines/reference/dynamicImportTrailingComma.errors.txt index fbae6f2c6ba78..f0c05146b7123 100644 --- a/tests/baselines/reference/dynamicImportTrailingComma.errors.txt +++ b/tests/baselines/reference/dynamicImportTrailingComma.errors.txt @@ -1,8 +1,11 @@ +tests/cases/compiler/dynamicImportTrailingComma.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/compiler/dynamicImportTrailingComma.ts(2,12): error TS1009: Trailing comma not allowed. -==== tests/cases/compiler/dynamicImportTrailingComma.ts (1 errors) ==== +==== tests/cases/compiler/dynamicImportTrailingComma.ts (2 errors) ==== const path = './foo'; import(path,); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ~ !!! error TS1009: Trailing comma not allowed. \ No newline at end of file diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es2015.errors.txt b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.errors.txt new file mode 100644 index 0000000000000..b8b7d5827abe6 --- /dev/null +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/dynamicImportWithNestedThis_es2015.ts(11,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/dynamicImportWithNestedThis_es2015.ts (1 errors) ==== + // https://github.com/Microsoft/TypeScript/issues/17564 + class C { + private _path = './other'; + + dynamic() { + return import(this._path); + } + } + + const c = new C(); + c.dynamic(); + ~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es5.errors.txt b/tests/baselines/reference/dynamicImportWithNestedThis_es5.errors.txt new file mode 100644 index 0000000000000..cf9c303ae43a1 --- /dev/null +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es5.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/dynamicImportWithNestedThis_es5.ts(11,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/dynamicImportWithNestedThis_es5.ts (1 errors) ==== + // https://github.com/Microsoft/TypeScript/issues/17564 + class C { + private _path = './other'; + + dynamic() { + return import(this._path); + } + } + + const c = new C(); + c.dynamic(); + ~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/errorForConflictingExportEqualsValue.errors.txt b/tests/baselines/reference/errorForConflictingExportEqualsValue.errors.txt index 19ebd6ebb20d9..3b4a542961d3a 100644 --- a/tests/baselines/reference/errorForConflictingExportEqualsValue.errors.txt +++ b/tests/baselines/reference/errorForConflictingExportEqualsValue.errors.txt @@ -1,10 +1,13 @@ /a.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +/a.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -==== /a.ts (1 errors) ==== +==== /a.ts (2 errors) ==== export var x; export = x; ~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. import("./a"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/es2018ObjectAssign.errors.txt b/tests/baselines/reference/es2018ObjectAssign.errors.txt new file mode 100644 index 0000000000000..6597bd22043f4 --- /dev/null +++ b/tests/baselines/reference/es2018ObjectAssign.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/es2018ObjectAssign.ts(4,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/es2018ObjectAssign.ts (1 errors) ==== + const test = Object.assign({}, { test: true }); + + declare const p: Promise; + p.finally(); + ~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/es2022SharedMemory.errors.txt b/tests/baselines/reference/es2022SharedMemory.errors.txt new file mode 100644 index 0000000000000..9a10ca79aef26 --- /dev/null +++ b/tests/baselines/reference/es2022SharedMemory.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/es2022/es2022SharedMemory.ts(17,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/es2022/es2022SharedMemory.ts (1 errors) ==== + const sab = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 1024); + const int32 = new Int32Array(sab); + const sab64 = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 1024); + const int64 = new BigInt64Array(sab64); + const waitValue = Atomics.wait(int32, 0, 0); + const { async, value } = Atomics.waitAsync(int32, 0, 0); + const { async: async64, value: value64 } = Atomics.waitAsync(int64, 0, BigInt(0)); + + const main = async () => { + if (async) { + await value; + } + if (async64) { + await value64; + } + } + main(); + ~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/esModuleInteropImportCall.errors.txt b/tests/baselines/reference/esModuleInteropImportCall.errors.txt new file mode 100644 index 0000000000000..4e51c2c968501 --- /dev/null +++ b/tests/baselines/reference/esModuleInteropImportCall.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/index.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/foo.d.ts (0 errors) ==== + declare function foo(): void; + declare namespace foo {} + export = foo; + +==== tests/cases/compiler/index.ts (1 errors) ==== + import("./foo").then(f => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + f.default; + ~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/exportDefaultAsyncFunction.errors.txt b/tests/baselines/reference/exportDefaultAsyncFunction.errors.txt new file mode 100644 index 0000000000000..16b519f12fd59 --- /dev/null +++ b/tests/baselines/reference/exportDefaultAsyncFunction.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/exportDefaultAsyncFunction.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/exportDefaultAsyncFunction.ts (1 errors) ==== + export default async function foo(): Promise {} + foo(); + ~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + \ No newline at end of file diff --git a/tests/baselines/reference/forAwaitPerIterationBindingDownlevel.errors.txt b/tests/baselines/reference/forAwaitPerIterationBindingDownlevel.errors.txt new file mode 100644 index 0000000000000..6f73b40494368 --- /dev/null +++ b/tests/baselines/reference/forAwaitPerIterationBindingDownlevel.errors.txt @@ -0,0 +1,54 @@ +tests/cases/conformance/statements/for-await-ofStatements/forAwaitPerIterationBindingDownlevel.ts(11,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/statements/for-await-ofStatements/forAwaitPerIterationBindingDownlevel.ts(14,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/statements/for-await-ofStatements/forAwaitPerIterationBindingDownlevel.ts (2 errors) ==== + const sleep = (tm: number) => new Promise(resolve => setTimeout(resolve, tm)); + + async function* gen() { + yield 1; + await sleep(1000); + yield 2; + } + + const log = console.log; + + (async () => { + ~~~~~~~~~~~~~~ + for await (const outer of gen()) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + log(`I'm loop ${outer}`); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + (async () => { + ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + const inner = outer; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + await sleep(2000); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if (inner === outer) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + log(`I'm loop ${inner} and I know I'm loop ${outer}`); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } else { + ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ + log(`I'm loop ${inner}, but I think I'm loop ${outer}`); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~~~~~~~~~ + ~~~~~~~~~~~~~ + })(); + ~~~~~~~~~~~~~ + ~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + ~~~~~ + })(); + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/genericFunctionInference1.errors.txt b/tests/baselines/reference/genericFunctionInference1.errors.txt index 5c910e7ff5d26..4f86ec041899c 100644 --- a/tests/baselines/reference/genericFunctionInference1.errors.txt +++ b/tests/baselines/reference/genericFunctionInference1.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/genericFunctionInference1.ts(135,14): error TS2345: Argument of type '(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'. Type 'number' is not assignable to type 'string'. +tests/cases/compiler/genericFunctionInference1.ts(196,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -==== tests/cases/compiler/genericFunctionInference1.ts (1 errors) ==== +==== tests/cases/compiler/genericFunctionInference1.ts (2 errors) ==== declare function pipe(ab: (...args: A) => B): (...args: A) => B; declare function pipe(ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C; declare function pipe(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D; @@ -202,11 +203,18 @@ tests/cases/compiler/genericFunctionInference1.ts(135,14): error TS2345: Argumen const promise = Promise.resolve(1); promise.then( + ~~~~~~~~~~~~~ pipe( + ~~~~~~~~~ x => x + 1, + ~~~~~~~~~~~~~~~~~~~ x => x * 2, + ~~~~~~~~~~~~~~~~~~~ ), + ~~~~~~ ); + ~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator // #29904.4 diff --git a/tests/baselines/reference/importCallExpression1ES2020.errors.txt b/tests/baselines/reference/importCallExpression1ES2020.errors.txt new file mode 100644 index 0000000000000..3e4883dcc4598 --- /dev/null +++ b/tests/baselines/reference/importCallExpression1ES2020.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }) + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } + \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpression2ES2020.errors.txt b/tests/baselines/reference/importCallExpression2ES2020.errors.txt new file mode 100644 index 0000000000000..4eca815beb721 --- /dev/null +++ b/tests/baselines/reference/importCallExpression2ES2020.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/dynamicImport/2.ts(2,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + function foo(x: Promise) { + x.then(value => { + ~~~~~~~~~~~~~~~~~ + let b = new value.B(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + b.print(); + ~~~~~~~~~~~~~~~~~~ + }) + ~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + + foo(import("./0")); + \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpression3ES2020.errors.txt b/tests/baselines/reference/importCallExpression3ES2020.errors.txt new file mode 100644 index 0000000000000..b6ca2178c8f2b --- /dev/null +++ b/tests/baselines/reference/importCallExpression3ES2020.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/dynamicImport/2.ts(6,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); + } + foo(); + ~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpression4ES2020.errors.txt b/tests/baselines/reference/importCallExpression4ES2020.errors.txt new file mode 100644 index 0000000000000..8fd06fccb4f1d --- /dev/null +++ b/tests/baselines/reference/importCallExpression4ES2020.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/dynamicImport/2.ts(6,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + + export function foo() { return "foo" } + +==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ==== + export function backup() { return "backup"; } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + declare var console: any; + class C { + private myModule = import("./0"); + method() { + const loadAsync = import ("./0"); + this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionDeclarationEmit1.errors.txt b/tests/baselines/reference/importCallExpressionDeclarationEmit1.errors.txt new file mode 100644 index 0000000000000..64a3ef8ad694c --- /dev/null +++ b/tests/baselines/reference/importCallExpressionDeclarationEmit1.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit1.ts(6,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit1.ts (1 errors) ==== + declare function getSpecifier(): string; + declare var whatToLoad: boolean; + declare const directory: string; + declare const moduleFile: number; + + import(getSpecifier()); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + var p0 = import(`${directory}\\${moduleFile}`); + var p1 = import(getSpecifier()); + const p2 = import(whatToLoad ? getSpecifier() : "defaulPath") + + function returnDynamicLoad(path: string) { + return import(path); + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionDeclarationEmit3.errors.txt b/tests/baselines/reference/importCallExpressionDeclarationEmit3.errors.txt new file mode 100644 index 0000000000000..2fe37b6138809 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionDeclarationEmit3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (1 errors) ==== + declare function getPath(): string; + import * as Zero from "./0"; + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p0: Promise = import(getPath()); + export var p1: Promise = import("./0"); + export var p2: Promise = import("./0"); + \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionES5AMD.errors.txt b/tests/baselines/reference/importCallExpressionES5AMD.errors.txt new file mode 100644 index 0000000000000..0d193e85f4aef --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES5AMD.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } + + class C { + method() { + const loadAsync = import ("./0"); + } + } + + export class D { + method() { + const loadAsync = import ("./0"); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionES5CJS.errors.txt b/tests/baselines/reference/importCallExpressionES5CJS.errors.txt new file mode 100644 index 0000000000000..0d193e85f4aef --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES5CJS.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } + + class C { + method() { + const loadAsync = import ("./0"); + } + } + + export class D { + method() { + const loadAsync = import ("./0"); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionES5System.errors.txt b/tests/baselines/reference/importCallExpressionES5System.errors.txt new file mode 100644 index 0000000000000..0d193e85f4aef --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES5System.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } + + class C { + method() { + const loadAsync = import ("./0"); + } + } + + export class D { + method() { + const loadAsync = import ("./0"); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionES5UMD.errors.txt b/tests/baselines/reference/importCallExpressionES5UMD.errors.txt new file mode 100644 index 0000000000000..0d193e85f4aef --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES5UMD.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } + + class C { + method() { + const loadAsync = import ("./0"); + } + } + + export class D { + method() { + const loadAsync = import ("./0"); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionES6AMD.errors.txt b/tests/baselines/reference/importCallExpressionES6AMD.errors.txt new file mode 100644 index 0000000000000..0d193e85f4aef --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6AMD.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } + + class C { + method() { + const loadAsync = import ("./0"); + } + } + + export class D { + method() { + const loadAsync = import ("./0"); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionES6CJS.errors.txt b/tests/baselines/reference/importCallExpressionES6CJS.errors.txt new file mode 100644 index 0000000000000..0d193e85f4aef --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6CJS.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } + + class C { + method() { + const loadAsync = import ("./0"); + } + } + + export class D { + method() { + const loadAsync = import ("./0"); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionES6System.errors.txt b/tests/baselines/reference/importCallExpressionES6System.errors.txt new file mode 100644 index 0000000000000..0d193e85f4aef --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6System.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } + + class C { + method() { + const loadAsync = import ("./0"); + } + } + + export class D { + method() { + const loadAsync = import ("./0"); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionES6UMD.errors.txt b/tests/baselines/reference/importCallExpressionES6UMD.errors.txt new file mode 100644 index 0000000000000..0d193e85f4aef --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6UMD.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } + + class C { + method() { + const loadAsync = import ("./0"); + } + } + + export class D { + method() { + const loadAsync = import ("./0"); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt index 5fbfb92fa50ea..d899731a84ccf 100644 --- a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt +++ b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt @@ -1,21 +1,29 @@ tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== export function foo() { return "foo"; } -==== tests/cases/conformance/dynamicImport/1.ts (3 errors) ==== +==== tests/cases/conformance/dynamicImport/1.ts (5 errors) ==== import("./0"); ~~~~~~~~~~~~~ !!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator var p1 = import("./0"); ~~~~~~~~~~~~~ !!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. p1.then(zero => { + ~~~~~~~~~~~~~~~~~ return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ }) + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator function foo() { const p2 = import("./0"); diff --git a/tests/baselines/reference/importCallExpressionGrammarError.errors.txt b/tests/baselines/reference/importCallExpressionGrammarError.errors.txt index ee698678c3c4d..afb7ec8ea926d 100644 --- a/tests/baselines/reference/importCallExpressionGrammarError.errors.txt +++ b/tests/baselines/reference/importCallExpressionGrammarError.errors.txt @@ -1,3 +1,4 @@ +tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(5,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(5,8): error TS1325: Argument of dynamic import cannot be spread element. tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(7,17): error TS1325: Argument of dynamic import cannot be spread element. tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(8,12): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments @@ -6,12 +7,14 @@ tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS2559: Type '"secondModule"' has no properties in common with type 'ImportCallOptions'. -==== tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts (6 errors) ==== +==== tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts (7 errors) ==== declare function getSpecifier(): string; declare var whatToLoad: boolean; var a = ["./0"]; import(...["PathModule"]); + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ~~~~~~~~~~~~~~~~~ !!! error TS1325: Argument of dynamic import cannot be spread element. diff --git a/tests/baselines/reference/importCallExpressionInAMD1.errors.txt b/tests/baselines/reference/importCallExpressionInAMD1.errors.txt new file mode 100644 index 0000000000000..d3d959a9c4f50 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInAMD1.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInAMD2.errors.txt b/tests/baselines/reference/importCallExpressionInAMD2.errors.txt new file mode 100644 index 0000000000000..a30007dfad121 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInAMD2.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/dynamicImport/2.ts(3,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + // We use Promise for now as there is no way to specify shape of module object + function foo(x: Promise) { + x.then(value => { + ~~~~~~~~~~~~~~~~~ + let b = new value.B(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + b.print(); + ~~~~~~~~~~~~~~~~~~ + }) + ~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + + foo(import("./0")); \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInAMD3.errors.txt b/tests/baselines/reference/importCallExpressionInAMD3.errors.txt new file mode 100644 index 0000000000000..b658df33edb53 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInAMD3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/dynamicImport/2.ts(6,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); + } + foo(); + ~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInAMD4.errors.txt b/tests/baselines/reference/importCallExpressionInAMD4.errors.txt new file mode 100644 index 0000000000000..913204e1815ec --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInAMD4.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/dynamicImport/2.ts(6,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/2.ts(20,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + + export function foo() { return "foo" } + +==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ==== + export function backup() { return "backup"; } + +==== tests/cases/conformance/dynamicImport/2.ts (2 errors) ==== + declare var console: any; + class C { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } + + export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInCJS1.errors.txt b/tests/baselines/reference/importCallExpressionInCJS1.errors.txt new file mode 100644 index 0000000000000..d3d959a9c4f50 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInCJS1.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInCJS2.errors.txt b/tests/baselines/reference/importCallExpressionInCJS2.errors.txt new file mode 100644 index 0000000000000..b0f81b7a50287 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInCJS2.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/dynamicImport/2.ts(10,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ==== + export function backup() { return "backup"; } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + async function compute(promise: Promise) { + let j = await promise; + if (!j) { + j = await import("./1"); + return j.backup(); + } + return j.foo(); + } + + compute(import("./0")); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInCJS3.errors.txt b/tests/baselines/reference/importCallExpressionInCJS3.errors.txt new file mode 100644 index 0000000000000..a30007dfad121 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInCJS3.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/dynamicImport/2.ts(3,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + // We use Promise for now as there is no way to specify shape of module object + function foo(x: Promise) { + x.then(value => { + ~~~~~~~~~~~~~~~~~ + let b = new value.B(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + b.print(); + ~~~~~~~~~~~~~~~~~~ + }) + ~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + + foo(import("./0")); \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInCJS4.errors.txt b/tests/baselines/reference/importCallExpressionInCJS4.errors.txt new file mode 100644 index 0000000000000..b658df33edb53 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInCJS4.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/dynamicImport/2.ts(6,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); + } + foo(); + ~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInCJS5.errors.txt b/tests/baselines/reference/importCallExpressionInCJS5.errors.txt new file mode 100644 index 0000000000000..5a3eeb1469dfd --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInCJS5.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/dynamicImport/2.ts(6,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/2.ts(20,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + + export function foo() { return "foo" } + +==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ==== + export function backup() { return "backup"; } + +==== tests/cases/conformance/dynamicImport/2.ts (2 errors) ==== + declare var console: any; + class C { + private myModule = import("./0"); + method() { + const loadAsync = import ("./0"); + this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } + + export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInSystem1.errors.txt b/tests/baselines/reference/importCallExpressionInSystem1.errors.txt new file mode 100644 index 0000000000000..d3d959a9c4f50 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInSystem1.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInSystem2.errors.txt b/tests/baselines/reference/importCallExpressionInSystem2.errors.txt new file mode 100644 index 0000000000000..a30007dfad121 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInSystem2.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/dynamicImport/2.ts(3,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + // We use Promise for now as there is no way to specify shape of module object + function foo(x: Promise) { + x.then(value => { + ~~~~~~~~~~~~~~~~~ + let b = new value.B(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + b.print(); + ~~~~~~~~~~~~~~~~~~ + }) + ~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + + foo(import("./0")); \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInSystem3.errors.txt b/tests/baselines/reference/importCallExpressionInSystem3.errors.txt new file mode 100644 index 0000000000000..b658df33edb53 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInSystem3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/dynamicImport/2.ts(6,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); + } + foo(); + ~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInSystem4.errors.txt b/tests/baselines/reference/importCallExpressionInSystem4.errors.txt new file mode 100644 index 0000000000000..913204e1815ec --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInSystem4.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/dynamicImport/2.ts(6,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/2.ts(20,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + + export function foo() { return "foo" } + +==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ==== + export function backup() { return "backup"; } + +==== tests/cases/conformance/dynamicImport/2.ts (2 errors) ==== + declare var console: any; + class C { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } + + export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInUMD1.errors.txt b/tests/baselines/reference/importCallExpressionInUMD1.errors.txt new file mode 100644 index 0000000000000..d3d959a9c4f50 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInUMD1.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(3,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export function foo() { return "foo"; } + +==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ==== + import("./0"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + var p1 = import("./0"); + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); + ~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + export var p2 = import("./0"); + + function foo() { + const p2 = import("./0"); + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInUMD2.errors.txt b/tests/baselines/reference/importCallExpressionInUMD2.errors.txt new file mode 100644 index 0000000000000..a30007dfad121 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInUMD2.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/dynamicImport/2.ts(3,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + // We use Promise for now as there is no way to specify shape of module object + function foo(x: Promise) { + x.then(value => { + ~~~~~~~~~~~~~~~~~ + let b = new value.B(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + b.print(); + ~~~~~~~~~~~~~~~~~~ + }) + ~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + + foo(import("./0")); \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInUMD3.errors.txt b/tests/baselines/reference/importCallExpressionInUMD3.errors.txt new file mode 100644 index 0000000000000..b658df33edb53 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInUMD3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/dynamicImport/2.ts(6,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + +==== tests/cases/conformance/dynamicImport/2.ts (1 errors) ==== + async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); + } + foo(); + ~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInUMD4.errors.txt b/tests/baselines/reference/importCallExpressionInUMD4.errors.txt new file mode 100644 index 0000000000000..913204e1815ec --- /dev/null +++ b/tests/baselines/reference/importCallExpressionInUMD4.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/dynamicImport/2.ts(6,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/2.ts(20,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== + export class B { + print() { return "I am B"} + } + + export function foo() { return "foo" } + +==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ==== + export function backup() { return "backup"; } + +==== tests/cases/conformance/dynamicImport/2.ts (2 errors) ==== + declare var console: any; + class C { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } + + export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.errors.txt b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.errors.txt index 550f7b85f3001..ab31cfa9ea9a2 100644 --- a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.errors.txt +++ b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.errors.txt @@ -1,6 +1,7 @@ error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/dynamicImport/2.ts(3,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/dynamicImport/2.ts(5,27): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +tests/cases/conformance/dynamicImport/2.ts(6,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/dynamicImport/2.ts(8,12): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/dynamicImport/2.ts(10,29): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -16,7 +17,7 @@ tests/cases/conformance/dynamicImport/2.ts(10,29): error TS2712: A dynamic impor ==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ==== export function backup() { return "backup"; } -==== tests/cases/conformance/dynamicImport/2.ts (4 errors) ==== +==== tests/cases/conformance/dynamicImport/2.ts (5 errors) ==== declare var console: any; class C { private myModule = import("./0"); @@ -27,15 +28,23 @@ tests/cases/conformance/dynamicImport/2.ts(10,29): error TS2712: A dynamic impor ~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. this.myModule.then(Zero => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ console.log(Zero.foo()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, async err => { + ~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. console.log(err); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ let one = await import("./1"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. console.log(one.backup()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.errors.txt b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.errors.txt new file mode 100644 index 0000000000000..f7681842c350b --- /dev/null +++ b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.errors.txt @@ -0,0 +1,48 @@ +tests/cases/conformance/dynamicImport/1.ts(8,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(9,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(15,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/1.ts(25,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/defaultPath.ts (0 errors) ==== + export class C {} + +==== tests/cases/conformance/dynamicImport/1.ts (4 errors) ==== + import * as defaultModule from "./defaultPath"; + declare function getSpecifier(): string; + declare function ValidSomeCondition(): boolean; + declare var whatToLoad: boolean; + declare const directory: string; + declare const moduleFile: number; + + import(`${directory}\\${moduleFile}`); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + import(getSpecifier()); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + var p1 = import(ValidSomeCondition() ? "./0" : "externalModule"); + var p1: Promise = import(getSpecifier()); + var p11: Promise = import(getSpecifier()); + const p2 = import(whatToLoad ? getSpecifier() : "defaulPath") as Promise; + p1.then(zero => { + ~~~~~~~~~~~~~~~~~ + return zero.foo(); // ok, zero is any + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + let j: string; + var p3: Promise = import(j=getSpecifier()); + + function * loadModule(directories: string[]) { + for (const directory of directories) { + const path = `${directory}\\moduleFile`; + import(yield path); + ~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionShouldNotGetParen.errors.txt b/tests/baselines/reference/importCallExpressionShouldNotGetParen.errors.txt new file mode 100644 index 0000000000000..c9b1c4847b29a --- /dev/null +++ b/tests/baselines/reference/importCallExpressionShouldNotGetParen.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/dynamicImport/importCallExpressionShouldNotGetParen.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/dynamicImport/importCallExpressionShouldNotGetParen.ts(6,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/dynamicImport/importCallExpressionShouldNotGetParen.ts (2 errors) ==== + const localeName = "zh-CN"; + import(`./locales/${localeName}.js`).then(bar => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let x = bar; + ~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + import("./locales/" + localeName + ".js").then(bar => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let x = bar; + ~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.errors.txt b/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.errors.txt index a1159a31ebd19..f1e8e69797994 100644 --- a/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.errors.txt +++ b/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.errors.txt @@ -1,16 +1,20 @@ +tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts(5,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts(5,8): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'boolean'. tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts(6,17): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'boolean'. tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts(7,19): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'boolean | "defaulPath"'. +tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts(8,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts(12,17): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'string[]'. tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts(13,17): error TS7036: Dynamic import's specifier must be of type 'string', but here has type '() => string'. -==== tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts (5 errors) ==== +==== tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts (7 errors) ==== declare function getSpecifier(): boolean; declare var whatToLoad: boolean; // Error specifier is not assignable to string import(getSpecifier()); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ~~~~~~~~~~~~~~ !!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'boolean'. var p1 = import(getSpecifier()); @@ -20,8 +24,12 @@ tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringType ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'boolean | "defaulPath"'. p1.then(zero => { + ~~~~~~~~~~~~~~~~~ return zero.foo(); // ok, zero is any + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator var p3 = import(["path1", "path2"]); ~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt index 2f65f3fc12c15..f44089bf9cdc5 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt +++ b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS13 tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. @@ -24,28 +25,41 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/es2019/importMeta/example.ts (4 errors) ==== +==== tests/cases/conformance/es2019/importMeta/example.ts (5 errors) ==== // Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example (async () => { + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. const blob = await response.blob(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const size = import.meta.scriptElement.dataset.size || 300; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. + const image = new Image(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.src = URL.createObjectURL(blob); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.width = image.height = size; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + document.body.appendChild(image); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })(); + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ==== export let x = import.meta; diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt index 2f65f3fc12c15..f44089bf9cdc5 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt +++ b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS13 tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. @@ -24,28 +25,41 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/es2019/importMeta/example.ts (4 errors) ==== +==== tests/cases/conformance/es2019/importMeta/example.ts (5 errors) ==== // Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example (async () => { + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. const blob = await response.blob(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const size = import.meta.scriptElement.dataset.size || 300; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. + const image = new Image(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.src = URL.createObjectURL(blob); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.width = image.height = size; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + document.body.appendChild(image); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })(); + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ==== export let x = import.meta; diff --git a/tests/baselines/reference/importMeta(module=es2020,target=es5).errors.txt b/tests/baselines/reference/importMeta(module=es2020,target=es5).errors.txt index 6c5e1b3dafde8..2f344ada6cd1a 100644 --- a/tests/baselines/reference/importMeta(module=es2020,target=es5).errors.txt +++ b/tests/baselines/reference/importMeta(module=es2020,target=es5).errors.txt @@ -2,6 +2,7 @@ error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es2019/importMeta/example.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -11,24 +12,37 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/es2019/importMeta/example.ts (2 errors) ==== +==== tests/cases/conformance/es2019/importMeta/example.ts (3 errors) ==== // Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example (async () => { + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const blob = await response.blob(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const size = import.meta.scriptElement.dataset.size || 300; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. + const image = new Image(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.src = URL.createObjectURL(blob); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.width = image.height = size; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + document.body.appendChild(image); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })(); + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (2 errors) ==== export let x = import.meta; diff --git a/tests/baselines/reference/importMeta(module=es2020,target=esnext).errors.txt b/tests/baselines/reference/importMeta(module=es2020,target=esnext).errors.txt index 6c5e1b3dafde8..2f344ada6cd1a 100644 --- a/tests/baselines/reference/importMeta(module=es2020,target=esnext).errors.txt +++ b/tests/baselines/reference/importMeta(module=es2020,target=esnext).errors.txt @@ -2,6 +2,7 @@ error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es2019/importMeta/example.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -11,24 +12,37 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/es2019/importMeta/example.ts (2 errors) ==== +==== tests/cases/conformance/es2019/importMeta/example.ts (3 errors) ==== // Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example (async () => { + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const blob = await response.blob(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const size = import.meta.scriptElement.dataset.size || 300; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. + const image = new Image(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.src = URL.createObjectURL(blob); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.width = image.height = size; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + document.body.appendChild(image); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })(); + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (2 errors) ==== export let x = import.meta; diff --git a/tests/baselines/reference/importMeta(module=esnext,target=es5).errors.txt b/tests/baselines/reference/importMeta(module=esnext,target=es5).errors.txt index 6c5e1b3dafde8..2f344ada6cd1a 100644 --- a/tests/baselines/reference/importMeta(module=esnext,target=es5).errors.txt +++ b/tests/baselines/reference/importMeta(module=esnext,target=es5).errors.txt @@ -2,6 +2,7 @@ error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es2019/importMeta/example.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -11,24 +12,37 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/es2019/importMeta/example.ts (2 errors) ==== +==== tests/cases/conformance/es2019/importMeta/example.ts (3 errors) ==== // Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example (async () => { + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const blob = await response.blob(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const size = import.meta.scriptElement.dataset.size || 300; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. + const image = new Image(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.src = URL.createObjectURL(blob); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.width = image.height = size; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + document.body.appendChild(image); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })(); + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (2 errors) ==== export let x = import.meta; diff --git a/tests/baselines/reference/importMeta(module=esnext,target=esnext).errors.txt b/tests/baselines/reference/importMeta(module=esnext,target=esnext).errors.txt index 6c5e1b3dafde8..2f344ada6cd1a 100644 --- a/tests/baselines/reference/importMeta(module=esnext,target=esnext).errors.txt +++ b/tests/baselines/reference/importMeta(module=esnext,target=esnext).errors.txt @@ -2,6 +2,7 @@ error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es2019/importMeta/example.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -11,24 +12,37 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/es2019/importMeta/example.ts (2 errors) ==== +==== tests/cases/conformance/es2019/importMeta/example.ts (3 errors) ==== // Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example (async () => { + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const blob = await response.blob(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const size = import.meta.scriptElement.dataset.size || 300; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. + const image = new Image(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.src = URL.createObjectURL(blob); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.width = image.height = size; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + document.body.appendChild(image); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })(); + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (2 errors) ==== export let x = import.meta; diff --git a/tests/baselines/reference/importMeta(module=system,target=es5).errors.txt b/tests/baselines/reference/importMeta(module=system,target=es5).errors.txt index 6c5e1b3dafde8..2f344ada6cd1a 100644 --- a/tests/baselines/reference/importMeta(module=system,target=es5).errors.txt +++ b/tests/baselines/reference/importMeta(module=system,target=es5).errors.txt @@ -2,6 +2,7 @@ error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es2019/importMeta/example.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -11,24 +12,37 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/es2019/importMeta/example.ts (2 errors) ==== +==== tests/cases/conformance/es2019/importMeta/example.ts (3 errors) ==== // Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example (async () => { + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const blob = await response.blob(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const size = import.meta.scriptElement.dataset.size || 300; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. + const image = new Image(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.src = URL.createObjectURL(blob); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.width = image.height = size; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + document.body.appendChild(image); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })(); + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (2 errors) ==== export let x = import.meta; diff --git a/tests/baselines/reference/importMeta(module=system,target=esnext).errors.txt b/tests/baselines/reference/importMeta(module=system,target=esnext).errors.txt index 6c5e1b3dafde8..2f344ada6cd1a 100644 --- a/tests/baselines/reference/importMeta(module=system,target=esnext).errors.txt +++ b/tests/baselines/reference/importMeta(module=system,target=esnext).errors.txt @@ -2,6 +2,7 @@ error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es2019/importMeta/example.ts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -11,24 +12,37 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/es2019/importMeta/example.ts (2 errors) ==== +==== tests/cases/conformance/es2019/importMeta/example.ts (3 errors) ==== // Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example (async () => { + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const blob = await response.blob(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const size = import.meta.scriptElement.dataset.size || 300; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. + const image = new Image(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.src = URL.createObjectURL(blob); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ image.width = image.height = size; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + document.body.appendChild(image); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })(); + ~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (2 errors) ==== export let x = import.meta; diff --git a/tests/baselines/reference/inferenceLimit.errors.txt b/tests/baselines/reference/inferenceLimit.errors.txt new file mode 100644 index 0000000000000..ec3b51e7267dd --- /dev/null +++ b/tests/baselines/reference/inferenceLimit.errors.txt @@ -0,0 +1,48 @@ +tests/cases/compiler/file1.ts(15,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/file1.ts (1 errors) ==== + "use strict"; + import * as MyModule from "./mymodule"; + + export class BrokenClass { + + constructor() {} + + public brokenMethod(field: string, value: string) { + return new Promise>((resolve, reject) => { + + let result: Array = []; + + let populateItems = (order) => { + return new Promise((resolve, reject) => { + this.doStuff(order.id) + ~~~~~~~~~~~~~~~~~~~~~~ + .then((items) => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + order.items = items; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + resolve(order); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + }); + }; + + return Promise.all(result.map(populateItems)) + .then((orders: Array) => { + resolve(orders); + }); + }); + } + + public async doStuff(id: number) { + return; + } + } + +==== tests/cases/compiler/mymodule.ts (0 errors) ==== + export interface MyModel { + id: number; + } \ No newline at end of file diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.errors.txt b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.errors.txt new file mode 100644 index 0000000000000..a9a8764da64a9 --- /dev/null +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.errors.txt @@ -0,0 +1,88 @@ +tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions1.ts(53,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions1.ts (1 errors) ==== + // Using Es6 array + function f(x: number, y: number, z: number) { + return Array.from(arguments); + } + + f(1, 2, 3); // no error + + // Using ES6 collection + var m = new Map(); + m.clear(); + // Using ES6 iterable + m.keys(); + + // Using ES6 function + function Baz() { } + Baz.name; + + // Using ES6 generator + function* gen() { + let i = 0; + while (i < 10) { + yield i; + i++; + } + } + + function* gen2() { + let i = 0; + while (i < 10) { + yield i; + i++; + } + } + + // Using ES6 math + Math.sign(1); + + // Using ES6 object + var o = { + a: 2, + [Symbol.hasInstance](value: any) { + return false; + } + }; + o.hasOwnProperty(Symbol.hasInstance); + + // Using ES6 promise + async function out() { + return new Promise(function (resolve, reject) {}); + } + + declare var console: any; + out().then(() => { + ~~~~~~~~~~~~~~~~~~ + console.log("Yea!"); + ~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + // Using Es6 proxy + var t = {} + var p = new Proxy(t, {}); + + // Using ES6 reflect + Reflect.isExtensible({}); + + // Using Es6 regexp + var reg = new RegExp("/s"); + reg.flags; + + // Using ES6 string + var str = "Hello world"; + str.includes("hello", 0); + + // Using ES6 symbol + var s = Symbol(); + + // Using ES6 wellknown-symbol + const o1 = { + [Symbol.hasInstance](value: any) { + return false; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.errors.txt b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.errors.txt new file mode 100644 index 0000000000000..34a53387afed8 --- /dev/null +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.errors.txt @@ -0,0 +1,88 @@ +tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions2.ts(53,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions2.ts (1 errors) ==== + // Using Es6 array + function f(x: number, y: number, z: number) { + return Array.from(arguments); + } + + f(1, 2, 3); // no error + + // Using ES6 collection + var m = new Map(); + m.clear(); + // Using ES6 iterable + m.keys(); + + // Using ES6 function + function Baz() { } + Baz.name; + + // Using ES6 generator + function* gen() { + let i = 0; + while (i < 10) { + yield i; + i++; + } + } + + function* gen2() { + let i = 0; + while (i < 10) { + yield i; + i++; + } + } + + // Using ES6 math + Math.sign(1); + + // Using ES6 object + var o = { + a: 2, + [Symbol.hasInstance](value: any) { + return false; + } + }; + o.hasOwnProperty(Symbol.hasInstance); + + // Using ES6 promise + async function out() { + return new Promise(function (resolve, reject) {}); + } + + declare var console: any; + out().then(() => { + ~~~~~~~~~~~~~~~~~~ + console.log("Yea!"); + ~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + // Using Es6 proxy + var t = {} + var p = new Proxy(t, {}); + + // Using ES6 reflect + Reflect.isExtensible({}); + + // Using Es6 regexp + var reg = new RegExp("/s"); + reg.flags; + + // Using ES6 string + var str = "Hello world"; + str.includes("hello", 0); + + // Using ES6 symbol + var s = Symbol(); + + // Using ES6 wellknown-symbol + const o1 = { + [Symbol.hasInstance](value: any) { + return false; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.errors.txt b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.errors.txt new file mode 100644 index 0000000000000..eda2911e836ad --- /dev/null +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.errors.txt @@ -0,0 +1,88 @@ +tests/cases/compiler/modularizeLibrary_TargetES5UsingES6Lib.ts(53,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/modularizeLibrary_TargetES5UsingES6Lib.ts (1 errors) ==== + // Using Es6 array + function f(x: number, y: number, z: number) { + return Array.from(arguments); + } + + f(1, 2, 3); // no error + + // Using ES6 collection + var m = new Map(); + m.clear(); + // Using ES6 iterable + m.keys(); + + // Using ES6 function + function Baz() { } + Baz.name; + + // Using ES6 generator + function* gen() { + let i = 0; + while (i < 10) { + yield i; + i++; + } + } + + function* gen2() { + let i = 0; + while (i < 10) { + yield i; + i++; + } + } + + // Using ES6 math + Math.sign(1); + + // Using ES6 object + var o = { + a: 2, + [Symbol.hasInstance](value: any) { + return false; + } + }; + o.hasOwnProperty(Symbol.hasInstance); + + // Using ES6 promise + async function out() { + return new Promise(function (resolve, reject) {}); + } + + declare var console: any; + out().then(() => { + ~~~~~~~~~~~~~~~~~~ + console.log("Yea!"); + ~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + // Using Es6 proxy + var t = {} + var p = new Proxy(t, {}); + + // Using ES6 reflect + Reflect.isExtensible({}); + + // Using Es6 regexp + var reg = new RegExp("/s"); + reg.flags; + + // Using ES6 string + var str = "Hello world"; + str.includes("hello", 0); + + // Using ES6 symbol + var s = Symbol(); + + // Using ES6 wellknown-symbol + const o1 = { + [Symbol.hasInstance](value: any) { + return false; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/moduleExportAliasImported.errors.txt b/tests/baselines/reference/moduleExportAliasImported.errors.txt new file mode 100644 index 0000000000000..400589fbea565 --- /dev/null +++ b/tests/baselines/reference/moduleExportAliasImported.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/salsa/importer.js(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/salsa/bug28014.js (0 errors) ==== + exports.version = 1 + function alias() { } + module.exports = alias + +==== tests/cases/conformance/salsa/importer.js (1 errors) ==== + import('./bug28014') + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt index 10ecfc258041c..e4d156bdba84e 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt @@ -1,13 +1,16 @@ error TS2468: Cannot find global value 'Promise'. /src/buzz.mts(2,1): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +/src/buzz.mts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator /src/buzz.mts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. !!! error TS2468: Cannot find global value 'Promise'. -==== /src/buzz.mts (2 errors) ==== +==== /src/buzz.mts (3 errors) ==== // Extensionless relative path dynamic import in an ES module import("./foo").then(x => x); // should error, ask for extension ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ~~~~~~~ !!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt index 4a551c88b9b78..3026b38845996 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt @@ -1,13 +1,16 @@ error TS2468: Cannot find global value 'Promise'. /src/bar.cts(2,1): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +/src/bar.cts(2,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator /src/bar.cts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. !!! error TS2468: Cannot find global value 'Promise'. -==== /src/bar.cts (2 errors) ==== +==== /src/bar.cts (3 errors) ==== // Extensionless relative path dynamic import in a cjs module import("./foo").then(x => x); // should error, ask for extension ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ~~~~~~~ !!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt index b729a7b742748..55ed181b1a7ce 100644 --- a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt @@ -1,10 +1,11 @@ -error TS-1: Pre-emit (13) and post-emit (14) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +error TS-1: Pre-emit (15) and post-emit (16) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(7,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/allowJs/index.js(8,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +tests/cases/conformance/node/allowJs/index.js(9,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -13,13 +14,14 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp tests/cases/conformance/node/allowJs/subfolder/index.js(6,23): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/allowJs/subfolder/index.js(7,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/allowJs/subfolder/index.js(8,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +tests/cases/conformance/node/allowJs/subfolder/index.js(9,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -!!! error TS-1: Pre-emit (13) and post-emit (14) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +!!! error TS-1: Pre-emit (15) and post-emit (16) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! !!! related TS-1: The excess diagnostics are: !!! related TS2705 /.src/tests/cases/conformance/node/allowJs/index.js:6:23: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/node/allowJs/subfolder/index.js (7 errors) ==== +==== tests/cases/conformance/node/allowJs/subfolder/index.js (8 errors) ==== // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ @@ -44,8 +46,10 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(8,24): error TS2712: A d ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. h(); + ~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } -==== tests/cases/conformance/node/allowJs/index.js (5 errors) ==== +==== tests/cases/conformance/node/allowJs/index.js (6 errors) ==== // esm format file import {h as _h} from "./index.js"; import mod = require("./index.js"); @@ -65,6 +69,8 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(8,24): error TS2712: A d ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. f(); + ~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } ==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt index b729a7b742748..55ed181b1a7ce 100644 --- a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt @@ -1,10 +1,11 @@ -error TS-1: Pre-emit (13) and post-emit (14) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +error TS-1: Pre-emit (15) and post-emit (16) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(7,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/allowJs/index.js(8,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +tests/cases/conformance/node/allowJs/index.js(9,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -13,13 +14,14 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp tests/cases/conformance/node/allowJs/subfolder/index.js(6,23): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/allowJs/subfolder/index.js(7,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/allowJs/subfolder/index.js(8,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +tests/cases/conformance/node/allowJs/subfolder/index.js(9,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -!!! error TS-1: Pre-emit (13) and post-emit (14) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +!!! error TS-1: Pre-emit (15) and post-emit (16) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! !!! related TS-1: The excess diagnostics are: !!! related TS2705 /.src/tests/cases/conformance/node/allowJs/index.js:6:23: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/node/allowJs/subfolder/index.js (7 errors) ==== +==== tests/cases/conformance/node/allowJs/subfolder/index.js (8 errors) ==== // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ @@ -44,8 +46,10 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(8,24): error TS2712: A d ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. h(); + ~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } -==== tests/cases/conformance/node/allowJs/index.js (5 errors) ==== +==== tests/cases/conformance/node/allowJs/index.js (6 errors) ==== // esm format file import {h as _h} from "./index.js"; import mod = require("./index.js"); @@ -65,6 +69,8 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(8,24): error TS2712: A d ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. f(); + ~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } ==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt index 8757dbcb62609..711cae8cecb05 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt @@ -1,21 +1,23 @@ -error TS-1: Pre-emit (9) and post-emit (10) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +error TS-1: Pre-emit (11) and post-emit (12) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/index.ts(7,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/index.ts(8,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +tests/cases/conformance/node/index.ts(9,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/subfolder/index.ts(6,23): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/subfolder/index.ts(7,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/subfolder/index.ts(8,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +tests/cases/conformance/node/subfolder/index.ts(9,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -!!! error TS-1: Pre-emit (9) and post-emit (10) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +!!! error TS-1: Pre-emit (11) and post-emit (12) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! !!! related TS-1: The excess diagnostics are: !!! related TS2705 /.src/tests/cases/conformance/node/index.ts:6:23: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/node/subfolder/index.ts (5 errors) ==== +==== tests/cases/conformance/node/subfolder/index.ts (6 errors) ==== // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ @@ -36,8 +38,10 @@ tests/cases/conformance/node/subfolder/index.ts(8,24): error TS2712: A dynamic i ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. h(); + ~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } -==== tests/cases/conformance/node/index.ts (3 errors) ==== +==== tests/cases/conformance/node/index.ts (4 errors) ==== // esm format file import {h as _h} from "./index.js"; import mod = require("./index.js"); @@ -53,6 +57,8 @@ tests/cases/conformance/node/subfolder/index.ts(8,24): error TS2712: A dynamic i ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. f(); + ~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } ==== tests/cases/conformance/node/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt index 8757dbcb62609..711cae8cecb05 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt @@ -1,21 +1,23 @@ -error TS-1: Pre-emit (9) and post-emit (10) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +error TS-1: Pre-emit (11) and post-emit (12) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/index.ts(7,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/index.ts(8,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +tests/cases/conformance/node/index.ts(9,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/subfolder/index.ts(6,23): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/subfolder/index.ts(7,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. tests/cases/conformance/node/subfolder/index.ts(8,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. +tests/cases/conformance/node/subfolder/index.ts(9,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -!!! error TS-1: Pre-emit (9) and post-emit (10) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +!!! error TS-1: Pre-emit (11) and post-emit (12) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! !!! related TS-1: The excess diagnostics are: !!! related TS2705 /.src/tests/cases/conformance/node/index.ts:6:23: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/conformance/node/subfolder/index.ts (5 errors) ==== +==== tests/cases/conformance/node/subfolder/index.ts (6 errors) ==== // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ @@ -36,8 +38,10 @@ tests/cases/conformance/node/subfolder/index.ts(8,24): error TS2712: A dynamic i ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. h(); + ~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } -==== tests/cases/conformance/node/index.ts (3 errors) ==== +==== tests/cases/conformance/node/index.ts (4 errors) ==== // esm format file import {h as _h} from "./index.js"; import mod = require("./index.js"); @@ -53,6 +57,8 @@ tests/cases/conformance/node/subfolder/index.ts(8,24): error TS2712: A dynamic i ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. f(); + ~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } ==== tests/cases/conformance/node/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/operationsAvailableOnPromisedType.errors.txt b/tests/baselines/reference/operationsAvailableOnPromisedType.errors.txt index db768ed1d81e8..61787383a335b 100644 --- a/tests/baselines/reference/operationsAvailableOnPromisedType.errors.txt +++ b/tests/baselines/reference/operationsAvailableOnPromisedType.errors.txt @@ -9,6 +9,7 @@ tests/cases/compiler/operationsAvailableOnPromisedType.ts(16,7): error TS2356: A tests/cases/compiler/operationsAvailableOnPromisedType.ts(17,5): error TS2367: This comparison appears to be unintentional because the types 'number' and 'Promise' have no overlap. tests/cases/compiler/operationsAvailableOnPromisedType.ts(18,9): error TS2461: Type 'Promise' is not an array type. tests/cases/compiler/operationsAvailableOnPromisedType.ts(19,21): error TS2495: Type 'Promise' is not an array type or a string type. +tests/cases/compiler/operationsAvailableOnPromisedType.ts(20,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/compiler/operationsAvailableOnPromisedType.ts(20,12): error TS2345: Argument of type 'Promise' is not assignable to parameter of type 'number'. tests/cases/compiler/operationsAvailableOnPromisedType.ts(21,11): error TS2339: Property 'prop' does not exist on type 'Promise<{ prop: string; }>'. tests/cases/compiler/operationsAvailableOnPromisedType.ts(23,27): error TS2495: Type 'Promise' is not an array type or a string type. @@ -24,7 +25,7 @@ tests/cases/compiler/operationsAvailableOnPromisedType.ts(27,5): error TS2349: T !!! error TS2468: Cannot find global value 'Promise'. -==== tests/cases/compiler/operationsAvailableOnPromisedType.ts (17 errors) ==== +==== tests/cases/compiler/operationsAvailableOnPromisedType.ts (18 errors) ==== async function fn( ~~ !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -72,6 +73,8 @@ tests/cases/compiler/operationsAvailableOnPromisedType.ts(27,5): error TS2349: T !!! error TS2495: Type 'Promise' is not an array type or a string type. !!! related TS2773 tests/cases/compiler/operationsAvailableOnPromisedType.ts:19:21: Did you forget to use 'await'? fn(b, b, c, d, e, f, g); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator ~ !!! error TS2345: Argument of type 'Promise' is not assignable to parameter of type 'number'. !!! related TS2773 tests/cases/compiler/operationsAvailableOnPromisedType.ts:20:12: Did you forget to use 'await'? diff --git a/tests/baselines/reference/outFilerootDirModuleNamesAmd.errors.txt b/tests/baselines/reference/outFilerootDirModuleNamesAmd.errors.txt new file mode 100644 index 0000000000000..5ad74f712f346 --- /dev/null +++ b/tests/baselines/reference/outFilerootDirModuleNamesAmd.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/moduleExportsAmd/src/b.ts(5,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/es6/moduleExportsAmd/src/a.ts (0 errors) ==== + import foo from "./b"; + export default class Foo {} + foo(); + +==== tests/cases/conformance/es6/moduleExportsAmd/src/b.ts (1 errors) ==== + import Foo from "./a"; + export default function foo() { new Foo(); } + + // https://github.com/microsoft/TypeScript/issues/37429 + import("./a"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/outFilerootDirModuleNamesSystem.errors.txt b/tests/baselines/reference/outFilerootDirModuleNamesSystem.errors.txt new file mode 100644 index 0000000000000..e7de74d403356 --- /dev/null +++ b/tests/baselines/reference/outFilerootDirModuleNamesSystem.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/es6/moduleExportsSystem/src/b.ts(5,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/es6/moduleExportsSystem/src/a.ts (0 errors) ==== + import foo from "./b"; + export default class Foo {} + foo(); + +==== tests/cases/conformance/es6/moduleExportsSystem/src/b.ts (1 errors) ==== + import Foo from "./a"; + export default function foo() { new Foo(); } + + // https://github.com/microsoft/TypeScript/issues/37429 + import("./a"); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + \ No newline at end of file diff --git a/tests/baselines/reference/privateNameMethodAsync.errors.txt b/tests/baselines/reference/privateNameMethodAsync.errors.txt new file mode 100644 index 0000000000000..0faff55d01b78 --- /dev/null +++ b/tests/baselines/reference/privateNameMethodAsync.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/classes/members/privateNames/privateNameMethodAsync.ts(13,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/classes/members/privateNames/privateNameMethodAsync.ts (1 errors) ==== + const C = class { + async #bar() { return await Promise.resolve(42); } + async foo() { + const b = await this.#bar(); + return b + (this.#baz().next().value || 0) + ((await this.#qux().next()).value || 0); + } + *#baz() { yield 42; } + async *#qux() { + yield (await Promise.resolve(42)); + } + } + + new C().foo().then(console.log); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + \ No newline at end of file diff --git a/tests/baselines/reference/privateNameStaticsAndStaticMethods(target=es2022).errors.txt b/tests/baselines/reference/privateNameStaticsAndStaticMethods(target=es2022).errors.txt new file mode 100644 index 0000000000000..75d8ea95e0050 --- /dev/null +++ b/tests/baselines/reference/privateNameStaticsAndStaticMethods(target=es2022).errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/classes/members/privateNames/privateNameStaticsAndStaticMethods.ts(16,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/classes/members/privateNames/privateNameStaticsAndStaticMethods.ts(17,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/classes/members/privateNames/privateNameStaticsAndStaticMethods.ts (2 errors) ==== + class A { + static #foo(a: number) {} + static async #bar(a: number) {} + static async *#baz(a: number) { + return 3; + } + static #_quux: number; + static get #quux (): number { + return this.#_quux; + } + static set #quux (val: number) { + this.#_quux = val; + } + constructor () { + A.#foo(30); + A.#bar(30); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + A.#bar(30); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + A.#quux = A.#quux + 1; + A.#quux++; + } + } + + class B extends A { + static #foo(a: string) {} + constructor () { + super(); + B.#foo("str"); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/privateNameStaticsAndStaticMethods(target=esnext).errors.txt b/tests/baselines/reference/privateNameStaticsAndStaticMethods(target=esnext).errors.txt new file mode 100644 index 0000000000000..75d8ea95e0050 --- /dev/null +++ b/tests/baselines/reference/privateNameStaticsAndStaticMethods(target=esnext).errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/classes/members/privateNames/privateNameStaticsAndStaticMethods.ts(16,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/classes/members/privateNames/privateNameStaticsAndStaticMethods.ts(17,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/classes/members/privateNames/privateNameStaticsAndStaticMethods.ts (2 errors) ==== + class A { + static #foo(a: number) {} + static async #bar(a: number) {} + static async *#baz(a: number) { + return 3; + } + static #_quux: number; + static get #quux (): number { + return this.#_quux; + } + static set #quux (val: number) { + this.#_quux = val; + } + constructor () { + A.#foo(30); + A.#bar(30); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + A.#bar(30); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + A.#quux = A.#quux + 1; + A.#quux++; + } + } + + class B extends A { + static #foo(a: string) {} + constructor () { + super(); + B.#foo("str"); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/privateNamesAndMethods(target=es2022).errors.txt b/tests/baselines/reference/privateNamesAndMethods(target=es2022).errors.txt new file mode 100644 index 0000000000000..941773e56f909 --- /dev/null +++ b/tests/baselines/reference/privateNamesAndMethods(target=es2022).errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/classes/members/privateNames/privateNamesAndMethods.ts(16,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/classes/members/privateNames/privateNamesAndMethods.ts (1 errors) ==== + class A { + #foo(a: number) {} + async #bar(a: number) {} + async *#baz(a: number) { + return 3; + } + #_quux: number; + get #quux (): number { + return this.#_quux; + } + set #quux (val: number) { + this.#_quux = val; + } + constructor () { + this.#foo(30); + this.#bar(30); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + this.#baz(30); + this.#quux = this.#quux + 1; + this.#quux++; + } + } + + class B extends A { + #foo(a: string) {} + constructor () { + super(); + this.#foo("str"); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/privateNamesAndMethods(target=esnext).errors.txt b/tests/baselines/reference/privateNamesAndMethods(target=esnext).errors.txt new file mode 100644 index 0000000000000..941773e56f909 --- /dev/null +++ b/tests/baselines/reference/privateNamesAndMethods(target=esnext).errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/classes/members/privateNames/privateNamesAndMethods.ts(16,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/classes/members/privateNames/privateNamesAndMethods.ts (1 errors) ==== + class A { + #foo(a: number) {} + async #bar(a: number) {} + async *#baz(a: number) { + return 3; + } + #_quux: number; + get #quux (): number { + return this.#_quux; + } + set #quux (val: number) { + this.#_quux = val; + } + constructor () { + this.#foo(30); + this.#bar(30); + ~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + this.#baz(30); + this.#quux = this.#quux + 1; + this.#quux++; + } + } + + class B extends A { + #foo(a: string) {} + constructor () { + super(); + this.#foo("str"); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/privateNamesAndStaticMethods(target=es2022).errors.txt b/tests/baselines/reference/privateNamesAndStaticMethods(target=es2022).errors.txt new file mode 100644 index 0000000000000..b07ebeea5e953 --- /dev/null +++ b/tests/baselines/reference/privateNamesAndStaticMethods(target=es2022).errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/classes/members/privateNames/privateNamesAndStaticMethods.ts(16,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/classes/members/privateNames/privateNamesAndStaticMethods.ts(17,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/classes/members/privateNames/privateNamesAndStaticMethods.ts (2 errors) ==== + class A { + static #foo(a: number) {} + static async #bar(a: number) {} + static async *#baz(a: number) { + return 3; + } + static #_quux: number; + static get #quux (): number { + return this.#_quux; + } + static set #quux (val: number) { + this.#_quux = val; + } + constructor () { + A.#foo(30); + A.#bar(30); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + A.#bar(30); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + A.#quux = A.#quux + 1; + A.#quux++; + } + } + + class B extends A { + static #foo(a: string) {} + constructor () { + super(); + B.#foo("str"); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/privateNamesAndStaticMethods(target=esnext).errors.txt b/tests/baselines/reference/privateNamesAndStaticMethods(target=esnext).errors.txt new file mode 100644 index 0000000000000..b07ebeea5e953 --- /dev/null +++ b/tests/baselines/reference/privateNamesAndStaticMethods(target=esnext).errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/classes/members/privateNames/privateNamesAndStaticMethods.ts(16,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/conformance/classes/members/privateNames/privateNamesAndStaticMethods.ts(17,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/conformance/classes/members/privateNames/privateNamesAndStaticMethods.ts (2 errors) ==== + class A { + static #foo(a: number) {} + static async #bar(a: number) {} + static async *#baz(a: number) { + return 3; + } + static #_quux: number; + static get #quux (): number { + return this.#_quux; + } + static set #quux (val: number) { + this.#_quux = val; + } + constructor () { + A.#foo(30); + A.#bar(30); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + A.#bar(30); + ~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + A.#quux = A.#quux + 1; + A.#quux++; + } + } + + class B extends A { + static #foo(a: string) {} + constructor () { + super(); + B.#foo("str"); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/promiseType.errors.txt b/tests/baselines/reference/promiseType.errors.txt new file mode 100644 index 0000000000000..2e1f216742cd6 --- /dev/null +++ b/tests/baselines/reference/promiseType.errors.txt @@ -0,0 +1,242 @@ +tests/cases/compiler/promiseType.ts(220,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/compiler/promiseType.ts(221,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/compiler/promiseType.ts(222,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/compiler/promiseType.ts(223,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator +tests/cases/compiler/promiseType.ts(224,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/promiseType.ts (5 errors) ==== + declare var p: Promise; + declare var x: any; + + async function A() { + const a = await p; + return a; + } + + async function B() { + const a = await p; + return 1; + } + + async function C() { + try { + const a = await p; + return 1; + } + catch (e) { + return 'error'; + } + } + + async function D() { + try { + const a = await p; + return 1; + } + catch (e) { + } + } + + async function E() { + try { + const a = await p; + return 1; + } + catch (e) { + throw Error(); + } + } + + async function F() { + try { + const a = await p; + return 1; + } + catch (e) { + return Promise.reject(Error()); + } + } + + async function G() { + try { + const a = await p; + return a; + } + catch (e) { + return; + } + } + + async function H() { + try { + const a = await p; + return a; + } + catch (e) { + throw Error(); + } + } + + async function I() { + try { + const a = await p; + return a; + } + catch (e) { + return Promise.reject(Error()); + } + } + + // addresses github issue #4903: + + const p00 = p.catch(); + const p01 = p.then(); + + const p10 = p.catch(undefined); + const p11 = p.catch(null); + const p12 = p.catch(() => 1); + const p13 = p.catch(() => x); + const p14 = p.catch(() => undefined); + const p15 = p.catch(() => null); + const p16 = p.catch(() => {}); + const p17 = p.catch(() => {throw 1}); + const p18 = p.catch(() => Promise.reject(1)); + const p19 = p.catch(() => Promise.resolve(1)); + + const p20 = p.then(undefined); + const p21 = p.then(null); + const p22 = p.then(() => 1); + const p23 = p.then(() => x); + const p24 = p.then(() => undefined); + const p25 = p.then(() => null); + const p26 = p.then(() => {}); + const p27 = p.then(() => {throw 1}); + const p28 = p.then(() => Promise.resolve(1)); + const p29 = p.then(() => Promise.reject(1)); + + const p30 = p.then(undefined, undefined); + const p31 = p.then(undefined, null); + const p32 = p.then(undefined, () => 1); + const p33 = p.then(undefined, () => x); + const p34 = p.then(undefined, () => undefined); + const p35 = p.then(undefined, () => null); + const p36 = p.then(undefined, () => {}); + const p37 = p.then(undefined, () => {throw 1}); + const p38 = p.then(undefined, () => Promise.resolve(1)); + const p39 = p.then(undefined, () => Promise.reject(1)); + + const p40 = p.then(null, undefined); + const p41 = p.then(null, null); + const p42 = p.then(null, () => 1); + const p43 = p.then(null, () => x); + const p44 = p.then(null, () => undefined); + const p45 = p.then(null, () => null); + const p46 = p.then(null, () => {}); + const p47 = p.then(null, () => {throw 1}); + const p48 = p.then(null, () => Promise.resolve(1)); + const p49 = p.then(null, () => Promise.reject(1)); + + const p50 = p.then(() => "1", undefined); + const p51 = p.then(() => "1", null); + const p52 = p.then(() => "1", () => 1); + const p53 = p.then(() => "1", () => x); + const p54 = p.then(() => "1", () => undefined); + const p55 = p.then(() => "1", () => null); + const p56 = p.then(() => "1", () => {}); + const p57 = p.then(() => "1", () => {throw 1}); + const p58 = p.then(() => "1", () => Promise.resolve(1)); + const p59 = p.then(() => "1", () => Promise.reject(1)); + + const p60 = p.then(() => x, undefined); + const p61 = p.then(() => x, null); + const p62 = p.then(() => x, () => 1); + const p63 = p.then(() => x, () => x); + const p64 = p.then(() => x, () => undefined); + const p65 = p.then(() => x, () => null); + const p66 = p.then(() => x, () => {}); + const p67 = p.then(() => x, () => {throw 1}); + const p68 = p.then(() => x, () => Promise.resolve(1)); + const p69 = p.then(() => x, () => Promise.reject(1)); + + const p70 = p.then(() => undefined, undefined); + const p71 = p.then(() => undefined, null); + const p72 = p.then(() => undefined, () => 1); + const p73 = p.then(() => undefined, () => x); + const p74 = p.then(() => undefined, () => undefined); + const p75 = p.then(() => undefined, () => null); + const p76 = p.then(() => undefined, () => {}); + const p77 = p.then(() => undefined, () => {throw 1}); + const p78 = p.then(() => undefined, () => Promise.resolve(1)); + const p79 = p.then(() => undefined, () => Promise.reject(1)); + + const p80 = p.then(() => null, undefined); + const p81 = p.then(() => null, null); + const p82 = p.then(() => null, () => 1); + const p83 = p.then(() => null, () => x); + const p84 = p.then(() => null, () => undefined); + const p85 = p.then(() => null, () => null); + const p86 = p.then(() => null, () => {}); + const p87 = p.then(() => null, () => {throw 1}); + const p88 = p.then(() => null, () => Promise.resolve(1)); + const p89 = p.then(() => null, () => Promise.reject(1)); + + const p90 = p.then(() => {}, undefined); + const p91 = p.then(() => {}, null); + const p92 = p.then(() => {}, () => 1); + const p93 = p.then(() => {}, () => x); + const p94 = p.then(() => {}, () => undefined); + const p95 = p.then(() => {}, () => null); + const p96 = p.then(() => {}, () => {}); + const p97 = p.then(() => {}, () => {throw 1}); + const p98 = p.then(() => {}, () => Promise.resolve(1)); + const p99 = p.then(() => {}, () => Promise.reject(1)); + + const pa0 = p.then(() => {throw 1}, undefined); + const pa1 = p.then(() => {throw 1}, null); + const pa2 = p.then(() => {throw 1}, () => 1); + const pa3 = p.then(() => {throw 1}, () => x); + const pa4 = p.then(() => {throw 1}, () => undefined); + const pa5 = p.then(() => {throw 1}, () => null); + const pa6 = p.then(() => {throw 1}, () => {}); + const pa7 = p.then(() => {throw 1}, () => {throw 1}); + const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1)); + const pa9 = p.then(() => {throw 1}, () => Promise.reject(1)); + + const pb0 = p.then(() => Promise.resolve("1"), undefined); + const pb1 = p.then(() => Promise.resolve("1"), null); + const pb2 = p.then(() => Promise.resolve("1"), () => 1); + const pb3 = p.then(() => Promise.resolve("1"), () => x); + const pb4 = p.then(() => Promise.resolve("1"), () => undefined); + const pb5 = p.then(() => Promise.resolve("1"), () => null); + const pb6 = p.then(() => Promise.resolve("1"), () => {}); + const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1}); + const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); + const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); + + const pc0 = p.then(() => Promise.reject("1"), undefined); + const pc1 = p.then(() => Promise.reject("1"), null); + const pc2 = p.then(() => Promise.reject("1"), () => 1); + const pc3 = p.then(() => Promise.reject("1"), () => x); + const pc4 = p.then(() => Promise.reject("1"), () => undefined); + const pc5 = p.then(() => Promise.reject("1"), () => null); + const pc6 = p.then(() => Promise.reject("1"), () => {}); + const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); + const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); + const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); + + Promise.resolve(undefined as Promise | number); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + Promise.resolve(undefined as Promise>); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + Promise.resolve(undefined as string | Promise>); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + Promise.resolve(undefined as Promise | Promise>); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + Promise.resolve(undefined as Promise>>); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/syntheticDefaultExportsWithDynamicImports.errors.txt b/tests/baselines/reference/syntheticDefaultExportsWithDynamicImports.errors.txt new file mode 100644 index 0000000000000..94bf61e6264e8 --- /dev/null +++ b/tests/baselines/reference/syntheticDefaultExportsWithDynamicImports.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/index.ts(1,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/node_modules/package/index.d.ts (0 errors) ==== + declare function packageExport(x: number): string; + export = packageExport; + +==== tests/cases/compiler/index.ts (1 errors) ==== + import("package").then(({default: foo}) => foo(42)); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/truthinessPromiseCoercion.errors.txt b/tests/baselines/reference/truthinessPromiseCoercion.errors.txt index b0c52a2cab78a..68667a2b36424 100644 --- a/tests/baselines/reference/truthinessPromiseCoercion.errors.txt +++ b/tests/baselines/reference/truthinessPromiseCoercion.errors.txt @@ -1,11 +1,13 @@ tests/cases/compiler/truthinessPromiseCoercion.ts(7,9): error TS2801: This condition will always return true since this 'Promise' is always defined. tests/cases/compiler/truthinessPromiseCoercion.ts(11,5): error TS2801: This condition will always return true since this 'Promise' is always defined. +tests/cases/compiler/truthinessPromiseCoercion.ts(19,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator tests/cases/compiler/truthinessPromiseCoercion.ts(32,9): error TS2801: This condition will always return true since this 'Promise' is always defined. tests/cases/compiler/truthinessPromiseCoercion.ts(40,9): error TS2801: This condition will always return true since this 'Promise' is always defined. tests/cases/compiler/truthinessPromiseCoercion.ts(43,9): error TS2801: This condition will always return true since this 'Promise' is always defined. +tests/cases/compiler/truthinessPromiseCoercion.ts(44,9): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -==== tests/cases/compiler/truthinessPromiseCoercion.ts (5 errors) ==== +==== tests/cases/compiler/truthinessPromiseCoercion.ts (7 errors) ==== declare const p: Promise declare const p2: null | Promise declare const obj: { p: Promise } @@ -31,6 +33,8 @@ tests/cases/compiler/truthinessPromiseCoercion.ts(43,9): error TS2801: This cond async function g() { if (p) { p; + ~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } if (p && p.then.length) {} if (p) { @@ -65,6 +69,8 @@ tests/cases/compiler/truthinessPromiseCoercion.ts(43,9): error TS2801: This cond !!! error TS2801: This condition will always return true since this 'Promise' is always defined. !!! related TS2773 tests/cases/compiler/truthinessPromiseCoercion.ts:43:9: Did you forget to use 'await'? pf().then(); + ~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator } return "false"; } diff --git a/tests/baselines/reference/unawaitedPromise.errors.txt b/tests/baselines/reference/unawaitedPromise.errors.txt new file mode 100644 index 0000000000000..ca1042350fd6e --- /dev/null +++ b/tests/baselines/reference/unawaitedPromise.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/unawaitedPromise.ts(5,5): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + +==== tests/cases/compiler/unawaitedPromise.ts (1 errors) ==== + declare function doThing(): Promise; + + function f() { + // Should error + doThing(); + ~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator + + let m: Promise; + // Should not error + m = doThing(); + + // Should not error + void doThing(); + } \ No newline at end of file diff --git a/tests/baselines/reference/unawaitedPromise.js b/tests/baselines/reference/unawaitedPromise.js new file mode 100644 index 0000000000000..44734fe8ed4a9 --- /dev/null +++ b/tests/baselines/reference/unawaitedPromise.js @@ -0,0 +1,26 @@ +//// [unawaitedPromise.ts] +declare function doThing(): Promise; + +function f() { + // Should error + doThing(); + + let m: Promise; + // Should not error + m = doThing(); + + // Should not error + void doThing(); +} + +//// [unawaitedPromise.js] +"use strict"; +function f() { + // Should error + doThing(); + var m; + // Should not error + m = doThing(); + // Should not error + void doThing(); +} diff --git a/tests/baselines/reference/unawaitedPromise.symbols b/tests/baselines/reference/unawaitedPromise.symbols new file mode 100644 index 0000000000000..04a9e421935ca --- /dev/null +++ b/tests/baselines/reference/unawaitedPromise.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/unawaitedPromise.ts === +declare function doThing(): Promise; +>doThing : Symbol(doThing, Decl(unawaitedPromise.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) + +function f() { +>f : Symbol(f, Decl(unawaitedPromise.ts, 0, 44)) + + // Should error + doThing(); +>doThing : Symbol(doThing, Decl(unawaitedPromise.ts, 0, 0)) + + let m: Promise; +>m : Symbol(m, Decl(unawaitedPromise.ts, 6, 7)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) + + // Should not error + m = doThing(); +>m : Symbol(m, Decl(unawaitedPromise.ts, 6, 7)) +>doThing : Symbol(doThing, Decl(unawaitedPromise.ts, 0, 0)) + + // Should not error + void doThing(); +>doThing : Symbol(doThing, Decl(unawaitedPromise.ts, 0, 0)) +} diff --git a/tests/baselines/reference/unawaitedPromise.types b/tests/baselines/reference/unawaitedPromise.types new file mode 100644 index 0000000000000..3f0916bffba75 --- /dev/null +++ b/tests/baselines/reference/unawaitedPromise.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/unawaitedPromise.ts === +declare function doThing(): Promise; +>doThing : () => Promise + +function f() { +>f : () => void + + // Should error + doThing(); +>doThing() : Promise +>doThing : () => Promise + + let m: Promise; +>m : Promise + + // Should not error + m = doThing(); +>m = doThing() : Promise +>m : Promise +>doThing() : Promise +>doThing : () => Promise + + // Should not error + void doThing(); +>void doThing() : undefined +>doThing() : Promise +>doThing : () => Promise +} diff --git a/tests/baselines/reference/unionOfClassCalls.errors.txt b/tests/baselines/reference/unionOfClassCalls.errors.txt index 386d34414bbf0..2c6bf9736f7fa 100644 --- a/tests/baselines/reference/unionOfClassCalls.errors.txt +++ b/tests/baselines/reference/unionOfClassCalls.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/unionOfClassCalls.ts(28,5): error TS2349: This expression is not callable. Each member of the union type '{ (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; } | { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; (callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }' has signatures, but none of those signatures are compatible with each other. +tests/cases/compiler/unionOfClassCalls.ts(74,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator -==== tests/cases/compiler/unionOfClassCalls.ts (1 errors) ==== +==== tests/cases/compiler/unionOfClassCalls.ts (2 errors) ==== // from https://github.com/microsoft/TypeScript/issues/30717 declare class Test { obj: T; @@ -80,6 +81,10 @@ tests/cases/compiler/unionOfClassCalls.ts(28,5): error TS2349: This expression i declare var a: Bar | Baz; // note, you must annotate `result` for now a.doThing().then((result: Bar | Baz) => { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // whatever + ~~~~~~~~~~~~ }); + ~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator \ No newline at end of file diff --git a/tests/baselines/reference/verbatimModuleSyntaxRestrictionsCJS.errors.txt b/tests/baselines/reference/verbatimModuleSyntaxRestrictionsCJS.errors.txt index 9bcb8b0214e39..e692f2c387f6c 100644 --- a/tests/baselines/reference/verbatimModuleSyntaxRestrictionsCJS.errors.txt +++ b/tests/baselines/reference/verbatimModuleSyntaxRestrictionsCJS.errors.txt @@ -2,6 +2,7 @@ /main.ts(2,13): error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled. /main.ts(3,10): error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled. /main.ts(5,1): error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled. +/main.ts(5,1): error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator /main.ts(8,1): error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled. /main.ts(14,1): error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled. /main2.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -22,7 +23,7 @@ export default _default; } -==== /main.ts (6 errors) ==== +==== /main.ts (7 errors) ==== import esmy from "./decl"; // error ~~~~ !!! error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled. @@ -36,6 +37,8 @@ import("./decl"); // error ~~~~~~~~~~~~~~~~ !!! error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled. + ~~~~~~~~~~~~~~~~ +!!! error TS7062: A Promise must be awaited, returned, or explicitly ignored with the 'void' operator type T = typeof import("./decl"); // ok export {}; // error export const x = 1; // error diff --git a/tests/cases/compiler/unawaitedPromise.ts b/tests/cases/compiler/unawaitedPromise.ts new file mode 100644 index 0000000000000..4d260fee95444 --- /dev/null +++ b/tests/cases/compiler/unawaitedPromise.ts @@ -0,0 +1,15 @@ +// @strict: true + +declare function doThing(): Promise; + +function f() { + // Should error + doThing(); + + let m: Promise; + // Should not error + m = doThing(); + + // Should not error + void doThing(); +} \ No newline at end of file diff --git a/tests/cases/fourslash/incrementalParsingDynamicImport1.ts b/tests/cases/fourslash/incrementalParsingDynamicImport1.ts index 557a05664fe7f..d6f480c1ed032 100644 --- a/tests/cases/fourslash/incrementalParsingDynamicImport1.ts +++ b/tests/cases/fourslash/incrementalParsingDynamicImport1.ts @@ -6,7 +6,7 @@ //// export function bar() { return 1; } //// var x1 = import("./foo"); -//// x1.then(foo => { +//// void x1.then(foo => { //// var s: string = foo.bar(); //// }) //// /*1*/