diff --git a/.changeset/stupid-numbers-hang.md b/.changeset/stupid-numbers-hang.md new file mode 100644 index 000000000000..b3fe379f4667 --- /dev/null +++ b/.changeset/stupid-numbers-hang.md @@ -0,0 +1,6 @@ +--- +swc_ecma_codegen: patch +swc_core: patch +--- + +fix(es/codegen): Emit comments of all nodes diff --git a/crates/swc/tests/fixture/issues-1xxx/1333/case2/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1333/case2/output/index.js index e04fbdd38ad3..85d369959a69 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1333/case2/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1333/case2/output/index.js @@ -1,4 +1,8 @@ -"use strict"; +/* + * Copyright (c) 2020. MeLike2D All Rights Reserved. + * Neo is licensed under the MIT License. + * See the LICENSE file in the project root for more details. + */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/crates/swc/tests/fixture/issues-1xxx/1345/output/index.ts b/crates/swc/tests/fixture/issues-1xxx/1345/output/index.ts index c46c7b906e15..37fbad844632 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1345/output/index.ts +++ b/crates/swc/tests/fixture/issues-1xxx/1345/output/index.ts @@ -1,4 +1,4 @@ -import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; +/** 등록된 계좌+회원의 정보 */ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata"; export var AccountMemberView = function AccountMemberView() { diff --git a/crates/swc/tests/fixture/issues-3xxx/3067/amd/output/packages/c/src/index.ts b/crates/swc/tests/fixture/issues-3xxx/3067/amd/output/packages/c/src/index.ts index bb3473afd71b..8e3b0d8eb446 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3067/amd/output/packages/c/src/index.ts +++ b/crates/swc/tests/fixture/issues-3xxx/3067/amd/output/packages/c/src/index.ts @@ -1,3 +1,4 @@ +// Simulate accessing a .js file in a third party package that shouldn't be edited define([ "require", "exports", diff --git a/crates/swc/tests/fixture/issues-3xxx/3067/commonjs/output/packages/c/src/index.ts b/crates/swc/tests/fixture/issues-3xxx/3067/commonjs/output/packages/c/src/index.ts index 67272da07a9d..25ebc7ba3ba1 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3067/commonjs/output/packages/c/src/index.ts +++ b/crates/swc/tests/fixture/issues-3xxx/3067/commonjs/output/packages/c/src/index.ts @@ -1,3 +1,4 @@ +// Simulate accessing a .js file in a third party package that shouldn't be edited "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/fixture/issues-3xxx/3067/systemjs/output/packages/c/src/index.ts b/crates/swc/tests/fixture/issues-3xxx/3067/systemjs/output/packages/c/src/index.ts index e1121fb27215..5fd339a641fd 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3067/systemjs/output/packages/c/src/index.ts +++ b/crates/swc/tests/fixture/issues-3xxx/3067/systemjs/output/packages/c/src/index.ts @@ -1,3 +1,4 @@ +// Simulate accessing a .js file in a third party package that shouldn't be edited System.register([ "lodash/dist/something.js" ], function(_export, _context) { diff --git a/crates/swc/tests/fixture/issues-3xxx/3067/umd/output/packages/c/src/index.ts b/crates/swc/tests/fixture/issues-3xxx/3067/umd/output/packages/c/src/index.ts index b2e268da0877..a97d841d1cac 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3067/umd/output/packages/c/src/index.ts +++ b/crates/swc/tests/fixture/issues-3xxx/3067/umd/output/packages/c/src/index.ts @@ -1,3 +1,4 @@ +// Simulate accessing a .js file in a third party package that shouldn't be edited (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@swc/helpers/_/_interop_require_default"), require("lodash/dist/something.js")); else if (typeof define === "function" && define.amd) define([ diff --git a/crates/swc/tests/fixture/issues-3xxx/3782/output/index.map b/crates/swc/tests/fixture/issues-3xxx/3782/output/index.map index c9e803e2ceaf..29307245a824 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3782/output/index.map +++ b/crates/swc/tests/fixture/issues-3xxx/3782/output/index.map @@ -1,5 +1,5 @@ { - "mappings": ";;;;;;;;QAKaA;eAAAA;;QAJDC;;;;qBAAS;AAId,MAAMD,OAAO,CAACE;IACjB,sBAAsB;IACtB,OAAO,IAAIC,QAAQ,CAACC,UAChBC,WAAW;YACPD,QAAQ;QACZ,GAAG;AAEX", + "mappings": "AAAA,WAAW;;;;;;;;;QAKEA;eAAAA;;QAJDC;;;;qBAAS;AAId,MAAMD,OAAO,CAACE;IACjB,sBAAsB;IACtB,OAAO,IAAIC,QAAQ,CAACC,UAChBC,WAAW;YACPD,QAAQ;QACZ,GAAG;AAEX", "names": [ "byID", "get", diff --git a/crates/swc/tests/fixture/issues-3xxx/3782/output/index.ts b/crates/swc/tests/fixture/issues-3xxx/3782/output/index.ts index c3d401efaf68..11f857ef8b77 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3782/output/index.ts +++ b/crates/swc/tests/fixture/issues-3xxx/3782/output/index.ts @@ -1,3 +1,4 @@ +// index.ts "use strict"; function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { diff --git a/crates/swc/tests/fixture/jest/issue-7506/output/index.map b/crates/swc/tests/fixture/jest/issue-7506/output/index.map index 4cb3968e73f0..6e59d7004275 100644 --- a/crates/swc/tests/fixture/jest/issue-7506/output/index.map +++ b/crates/swc/tests/fixture/jest/issue-7506/output/index.map @@ -1,5 +1,5 @@ { - "mappings": ";;;;+BAE8B;AAE9BA,SAAS,mBAAmB;IACxBC,GAAG,4DAA4D;QAC3D,IAAIC;QACJ,SAASC;YACLD,QAAQE,IAAAA,4BAAa;QACzB;QACAD;QAEAE,OAAOH,KAAK,CAAC,EAAE,EAAEI,SAAS,CAAC;IAC/B;AACJ", + "mappings": "AAAA,4DAA4D;AAC5D,kCAAkC;;;;;+BACJ;AAE9BA,SAAS,mBAAmB;IACxBC,GAAG,4DAA4D;QAC3D,IAAIC;QACJ,SAASC;YACLD,QAAQE,IAAAA,4BAAa;QACzB;QACAD;QAEAE,OAAOH,KAAK,CAAC,EAAE,EAAEI,SAAS,CAAC;IAC/B;AACJ", "names": [ "describe", "it", diff --git a/crates/swc/tests/fixture/jest/issue-7506/output/index.ts b/crates/swc/tests/fixture/jest/issue-7506/output/index.ts index 57ce131ac195..9684ea8f6345 100644 --- a/crates/swc/tests/fixture/jest/issue-7506/output/index.ts +++ b/crates/swc/tests/fixture/jest/issue-7506/output/index.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/fixture/jest/issue-7506/output/util.map b/crates/swc/tests/fixture/jest/issue-7506/output/util.map index 461c4e4a2ee0..741eb2e4f9db 100644 --- a/crates/swc/tests/fixture/jest/issue-7506/output/util.map +++ b/crates/swc/tests/fixture/jest/issue-7506/output/util.map @@ -1,5 +1,5 @@ { - "mappings": ";;;;+BAGgBA;;;eAAAA;;;AAAT,SAASA;IACZ,MAAMC,WAAW,IAAIC,QAAQC,KAAK;IAElC,OAAOF,SAASG,KAAK,CAAC;AAC1B", + "mappings": "AAAA,4DAA4D;AAC5D,kCAAkC;;;;;+BAElBA;;;eAAAA;;;AAAT,SAASA;IACZ,MAAMC,WAAW,IAAIC,QAAQC,KAAK;IAElC,OAAOF,SAASG,KAAK,CAAC;AAC1B", "names": [ "getStackTrace", "rawStack", diff --git a/crates/swc/tests/fixture/jest/issue-7506/output/util.ts b/crates/swc/tests/fixture/jest/issue-7506/output/util.ts index 75f12cabd1fd..958573b76ef7 100644 --- a/crates/swc/tests/fixture/jest/issue-7506/output/util.ts +++ b/crates/swc/tests/fixture/jest/issue-7506/output/util.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts index 6164176d4f22..957cf93822d1 100644 --- a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts +++ b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts @@ -1,4 +1,19 @@ /** + * Generate secure URL-friendly unique ID. The non-blocking version. + * + * By default, the ID will have 21 symbols to have a collision probability + * similar to UUID v4. + * + * ```js + * import { nanoid } from 'nanoid/async' + * nanoid().then(id => { + * model.id = id + * }) + * ``` + * + * @param size Size of the ID. The default size is 21. + * @returns A promise with a random string. + */ /** * Generate an array of random bytes collected from hardware noise. * * ```js diff --git a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.d.ts b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.d.ts index 7d4587ed1d96..313a66cef825 100644 --- a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.d.ts +++ b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/index.d.ts @@ -1,4 +1,17 @@ /** + * Generate secure URL-friendly unique ID. + * + * By default, the ID will have 21 symbols to have a collision probability + * similar to UUID v4. + * + * ```js + * import { nanoid } from 'nanoid' + * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL" + * ``` + * + * @param size Size of the ID. The default size is 21. + * @returns A random string. + */ /** * URL safe symbols. * * ```js diff --git a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts index 524dd7fd1a4b..604cc919fad5 100644 --- a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts +++ b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts @@ -1,4 +1,15 @@ /** + * Generate URL-friendly unique ID. This method uses the non-secure + * predictable random generator with bigger collision probability. + * + * ```js + * import { nanoid } from 'nanoid/non-secure' + * model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL" + * ``` + * + * @param size Size of the ID. The default size is 21. + * @returns A random string. + */ /** * Generate a unique ID based on a custom alphabet. * This method uses the non-secure predictable random generator * with bigger collision probability. diff --git a/crates/swc/tests/tsc-references/accessorsOverrideProperty9.1.normal.js b/crates/swc/tests/tsc-references/accessorsOverrideProperty9.1.normal.js index 599376e4d0d8..ec780f129760 100644 --- a/crates/swc/tests/tsc-references/accessorsOverrideProperty9.1.normal.js +++ b/crates/swc/tests/tsc-references/accessorsOverrideProperty9.1.normal.js @@ -1,4 +1,6 @@ //// [accessorsOverrideProperty9.ts] +// #41347, based on microsoft/rushstack +// Mixin utilities // Base class class ApiItem { get members() { diff --git a/crates/swc/tests/tsc-references/ambientDeclarations.1.normal.js b/crates/swc/tests/tsc-references/ambientDeclarations.1.normal.js index 27067142cfab..a5ee7ff03c86 100644 --- a/crates/swc/tests/tsc-references/ambientDeclarations.1.normal.js +++ b/crates/swc/tests/tsc-references/ambientDeclarations.1.normal.js @@ -1,4 +1,5 @@ //// [ambientDeclarations.ts] +// Ambient variable without type annotation var x = E3.B; // Ambient module members are always exported with or without export keyword var p = M1.x; diff --git a/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.1.normal.js b/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.1.normal.js index f9fcd2f7c607..474ca025ad1f 100644 --- a/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.1.normal.js +++ b/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.1.normal.js @@ -1,4 +1,5 @@ //// [anyAssignabilityInInheritance.ts] +// any is not a subtype of any other types, errors expected on all the below derived classes unless otherwise noted import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var a; var r3 = foo2(a); // any, not a subtype of number so it skips that overload, is a subtype of itself so it picks second (if truly ambiguous it would pick first overload) diff --git a/crates/swc/tests/tsc-references/anyAssignableToEveryType2.1.normal.js b/crates/swc/tests/tsc-references/anyAssignableToEveryType2.1.normal.js index 46a4e21ee663..ba7dac5d9430 100644 --- a/crates/swc/tests/tsc-references/anyAssignableToEveryType2.1.normal.js +++ b/crates/swc/tests/tsc-references/anyAssignableToEveryType2.1.normal.js @@ -1,4 +1,5 @@ //// [anyAssignableToEveryType2.ts] +// any is not a subtype of any other types, but is assignable, all the below should work import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var A = function A() { "use strict"; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures.1.normal.js index 122b4fda5915..3d32b5a93eb3 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithCallSignatures.ts] +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches var t; var a; t = a; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures2.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures2.1.normal.js index 890fe2a75871..c914454a3aea 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures2.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures2.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithCallSignatures2.ts] +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches var t; var a; t = a; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignaturesWithOptionalParameters.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignaturesWithOptionalParameters.1.normal.js index 6647d133242a..ccc2e04aa69b 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignaturesWithOptionalParameters.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignaturesWithOptionalParameters.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithCallSignaturesWithOptionalParameters.ts] +// call signatures in derived types must have the same or fewer optional parameters as the base type var b; var a; a = function() { diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignaturesWithRestParameters.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignaturesWithRestParameters.1.normal.js index 0cd8fc7d6624..55338c2a6e73 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignaturesWithRestParameters.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignaturesWithRestParameters.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithCallSignaturesWithRestParameters.ts] +// call signatures in derived types must have the same or fewer optional parameters as the target for assignment var a; // ok, same number of required params a = function() { return 1; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures.1.normal.js index 8ea69ee0f92e..a19f73a9564e 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithConstructSignatures.ts] +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches var t; var a; t = a; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures2.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures2.1.normal.js index b381f86b78c0..35a9c3cc9037 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures2.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures2.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithConstructSignatures2.ts] +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches var t; var a; t = a; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignaturesWithOptionalParameters.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignaturesWithOptionalParameters.1.normal.js index 80a4d4fb4213..f9274e6fa811 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignaturesWithOptionalParameters.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignaturesWithOptionalParameters.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithConstructSignaturesWithOptionalParameters.ts] +// call signatures in derived types must have the same or fewer optional parameters as the base type var b; var a; a = b.a; // ok diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures2.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures2.1.normal.js index b479740b0427..396ed8366196 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures2.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures2.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithGenericCallSignatures2.ts] +// some complex cases of assignment compat of generic signatures. No contextual signature instantiation var a; var b; // Both errors diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures3.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures3.1.normal.js index 58aae06c481b..8b35270ba842 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures3.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures3.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithGenericCallSignatures3.ts] +// some complex cases of assignment compat of generic signatures that stress contextual signature instantiation var g; var h; g = h; // ok diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures4.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures4.1.normal.js index 9f08dea55973..c7296f2073c7 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures4.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignatures4.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithGenericCallSignatures4.ts] +// some complex cases of assignment compat of generic signatures. var x; var y; // These both do not make sense as we would eventually be comparing I2 to I2>, and they are self referencing anyway diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer.1.normal.js index 9b13850310b7..802f5f0e921c 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithNumericIndexer.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2.1.normal.js index 1cc8131338e2..16ae938c2c29 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithNumericIndexer2.ts] +// Derived type indexer must be subtype of base type indexer var a; var b; a = b; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer3.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer3.1.normal.js index 5541208de6b3..3e0ca9e7e91a 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer3.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer3.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithNumericIndexer3.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer.1.normal.js index 61bf6a381833..a55641a58fa5 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithStringIndexer.ts] +// index signatures must be compatible in assignments import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2.1.normal.js index 672dfb81a987..543e257a7810 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithStringIndexer2.ts] +// index signatures must be compatible in assignments var a; var b; a = b; // ok diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer3.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer3.1.normal.js index 84aebf1c5661..b1ea4e691ca1 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer3.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer3.1.normal.js @@ -1,4 +1,5 @@ //// [assignmentCompatWithStringIndexer3.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var a; var b1; diff --git a/crates/swc/tests/tsc-references/assignments.1.normal.js b/crates/swc/tests/tsc-references/assignments.1.normal.js index 59a591fc0543..8dfefb0c6613 100644 --- a/crates/swc/tests/tsc-references/assignments.1.normal.js +++ b/crates/swc/tests/tsc-references/assignments.1.normal.js @@ -1,4 +1,12 @@ //// [assignments.ts] +// In this file: +// Assign to a module +// Assign to a class +// Assign to an enum +// Assign to a function +// Assign to a variable +// Assign to a parameter +// Assign to an interface import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; M = null; // Error var C = function C() { diff --git a/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6.1.normal.js b/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6.1.normal.js index 9b110ac4e905..6938a4d03ee2 100644 --- a/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncWithVarShadowing_es6.1.normal.js @@ -1,4 +1,5 @@ //// [asyncWithVarShadowing_es6.ts] +// https://github.com/Microsoft/TypeScript/issues/20461 import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _extends } from "@swc/helpers/_/_extends"; import { _ as _object_destructuring_empty } from "@swc/helpers/_/_object_destructuring_empty"; diff --git a/crates/swc/tests/tsc-references/bivariantInferences.1.normal.js b/crates/swc/tests/tsc-references/bivariantInferences.1.normal.js index dc41689c348b..7b514081ce78 100644 --- a/crates/swc/tests/tsc-references/bivariantInferences.1.normal.js +++ b/crates/swc/tests/tsc-references/bivariantInferences.1.normal.js @@ -1,2 +1,3 @@ //// [bivariantInferences.ts] +// Repro from #27337 var x = a.equalsShallow(b); diff --git a/crates/swc/tests/tsc-references/callChainInference.1.normal.js b/crates/swc/tests/tsc-references/callChainInference.1.normal.js index 8404ba27c0fc..045ee5d9a33e 100644 --- a/crates/swc/tests/tsc-references/callChainInference.1.normal.js +++ b/crates/swc/tests/tsc-references/callChainInference.1.normal.js @@ -1,4 +1,5 @@ //// [callChainInference.ts] +// Repro from #42404 if (value) { value === null || value === void 0 ? void 0 : value.foo("a"); } diff --git a/crates/swc/tests/tsc-references/callSignaturesThatDifferOnlyByReturnType.1.normal.js b/crates/swc/tests/tsc-references/callSignaturesThatDifferOnlyByReturnType.1.normal.js index 6c8254cb6a2b..a146ec37f19a 100644 --- a/crates/swc/tests/tsc-references/callSignaturesThatDifferOnlyByReturnType.1.normal.js +++ b/crates/swc/tests/tsc-references/callSignaturesThatDifferOnlyByReturnType.1.normal.js @@ -1,3 +1,5 @@ //// [callSignaturesThatDifferOnlyByReturnType.ts] +// Each pair of signatures in these types has a signature that should cause an error. +// Overloads, generic or not, that differ only by return type are an error. var a; var a2; diff --git a/crates/swc/tests/tsc-references/callSignaturesThatDifferOnlyByReturnType2.1.normal.js b/crates/swc/tests/tsc-references/callSignaturesThatDifferOnlyByReturnType2.1.normal.js index 44a189585b73..87022c89a733 100644 --- a/crates/swc/tests/tsc-references/callSignaturesThatDifferOnlyByReturnType2.1.normal.js +++ b/crates/swc/tests/tsc-references/callSignaturesThatDifferOnlyByReturnType2.1.normal.js @@ -1,4 +1,6 @@ //// [callSignaturesThatDifferOnlyByReturnType2.ts] +// Normally it is an error to have multiple overloads which differ only by return type in a single type declaration. +// Here the multiple overloads come from multiple bases. var x; // BUG 822524 var r = x.foo(1); // no error diff --git a/crates/swc/tests/tsc-references/callSignaturesWithOptionalParameters2.1.normal.js b/crates/swc/tests/tsc-references/callSignaturesWithOptionalParameters2.1.normal.js index 6f20c1c20d30..f1a5cc98b41b 100644 --- a/crates/swc/tests/tsc-references/callSignaturesWithOptionalParameters2.1.normal.js +++ b/crates/swc/tests/tsc-references/callSignaturesWithOptionalParameters2.1.normal.js @@ -1,4 +1,5 @@ //// [callSignaturesWithOptionalParameters2.ts] +// Optional parameters should be valid in all the below casts import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function foo(x) {} foo(1); diff --git a/crates/swc/tests/tsc-references/comparisonOperatorWithNumberOperand.1.normal.js b/crates/swc/tests/tsc-references/comparisonOperatorWithNumberOperand.1.normal.js index 1168ea7cbf04..e439ace35bad 100644 --- a/crates/swc/tests/tsc-references/comparisonOperatorWithNumberOperand.1.normal.js +++ b/crates/swc/tests/tsc-references/comparisonOperatorWithNumberOperand.1.normal.js @@ -1,2 +1,3 @@ //// [comparisonOperatorWithNumberOperand.ts] +// repro #52036 t1 >= 0; // error diff --git a/crates/swc/tests/tsc-references/constEnumNoObjectPrototypePropertyAccess.1.normal.js b/crates/swc/tests/tsc-references/constEnumNoObjectPrototypePropertyAccess.1.normal.js index b15c1677d73e..74af9bc68610 100644 --- a/crates/swc/tests/tsc-references/constEnumNoObjectPrototypePropertyAccess.1.normal.js +++ b/crates/swc/tests/tsc-references/constEnumNoObjectPrototypePropertyAccess.1.normal.js @@ -1,4 +1,5 @@ //// [constEnumNoObjectPrototypePropertyAccess.ts] +// https://github.com/microsoft/TypeScript/issues/55421 console.log(Bebra.constructor); console.log(Bebra.hasOwnProperty); console.log(Bebra.isPrototypeOf); diff --git a/crates/swc/tests/tsc-references/constEnumPropertyAccess1.1.normal.js b/crates/swc/tests/tsc-references/constEnumPropertyAccess1.1.normal.js index 5a9f45faefb5..25e21ce4deb2 100644 --- a/crates/swc/tests/tsc-references/constEnumPropertyAccess1.1.normal.js +++ b/crates/swc/tests/tsc-references/constEnumPropertyAccess1.1.normal.js @@ -1,4 +1,7 @@ //// [constEnumPropertyAccess1.ts] +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members var o = { 1: true }; diff --git a/crates/swc/tests/tsc-references/constEnumPropertyAccess2.1.normal.js b/crates/swc/tests/tsc-references/constEnumPropertyAccess2.1.normal.js index dfd4920cb55b..fa167d11292c 100644 --- a/crates/swc/tests/tsc-references/constEnumPropertyAccess2.1.normal.js +++ b/crates/swc/tests/tsc-references/constEnumPropertyAccess2.1.normal.js @@ -1,4 +1,7 @@ //// [constEnumPropertyAccess2.ts] +// constant enum declarations are completely erased in the emitted JavaScript code. +// it is an error to reference a constant enum object in any other context +// than a property access that selects one of the enum's members // Error from referring constant enum in any other context than a property access var z = G; var z1 = G[1]; diff --git a/crates/swc/tests/tsc-references/constraintSatisfactionWithAny2.1.normal.js b/crates/swc/tests/tsc-references/constraintSatisfactionWithAny2.1.normal.js index 8c8fdc7cdb3b..90e5c2b881ae 100644 --- a/crates/swc/tests/tsc-references/constraintSatisfactionWithAny2.1.normal.js +++ b/crates/swc/tests/tsc-references/constraintSatisfactionWithAny2.1.normal.js @@ -1,4 +1,6 @@ //// [constraintSatisfactionWithAny2.ts] +// errors expected for type parameter cannot be referenced in the constraints of the same list +// any is not a valid type argument unless there is no constraint, or the constraint is any var a; foo(a); foo(a); diff --git a/crates/swc/tests/tsc-references/constructSignatureAssignabilityInInheritance.1.normal.js b/crates/swc/tests/tsc-references/constructSignatureAssignabilityInInheritance.1.normal.js index 90904024534e..41193cb6e649 100644 --- a/crates/swc/tests/tsc-references/constructSignatureAssignabilityInInheritance.1.normal.js +++ b/crates/swc/tests/tsc-references/constructSignatureAssignabilityInInheritance.1.normal.js @@ -1,4 +1,5 @@ //// [constructSignatureAssignabilityInInheritance.ts] +// Checking basic subtype relations with construct signatures (function(MemberWithConstructSignature) { var b; var r = new b.a(1); diff --git a/crates/swc/tests/tsc-references/contextualSignatureInstantiation.1.normal.js b/crates/swc/tests/tsc-references/contextualSignatureInstantiation.1.normal.js index 41a5625f0ec3..cc1f4f79a767 100644 --- a/crates/swc/tests/tsc-references/contextualSignatureInstantiation.1.normal.js +++ b/crates/swc/tests/tsc-references/contextualSignatureInstantiation.1.normal.js @@ -1,4 +1,9 @@ //// [contextualSignatureInstantiation.ts] +// TypeScript Spec, section 4.12.2: +// If e is an expression of a function type that contains exactly one generic call signature and no other members, +// and T is a function type with exactly one non - generic call signature and no other members, then any inferences +// made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed +// to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5). var a; var a = bar(1, 1, g); // Should be number var a = baz(1, 1, g); // Should be number diff --git a/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeCallSignatures.1.normal.js b/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeCallSignatures.1.normal.js index 28053e41df0f..612f152033ae 100644 --- a/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeCallSignatures.1.normal.js +++ b/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeCallSignatures.1.normal.js @@ -1,4 +1,9 @@ //// [contextualTypeWithUnionTypeCallSignatures.ts] +//When used as a contextual type, a union type U has those members that are present in any of +// its constituent types, with types that are unions of the respective members in the constituent types. +// Let S be the set of types in U that have call signatures. +// If S is not empty and the sets of call signatures of the types in S are identical ignoring return types, +// U has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in S. // With no call signature | callSignatures var x = function(a) { return a.toString(); diff --git a/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeIndexSignatures.1.normal.js b/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeIndexSignatures.1.normal.js index b773439b7921..19b57567f454 100644 --- a/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeIndexSignatures.1.normal.js +++ b/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeIndexSignatures.1.normal.js @@ -1,4 +1,6 @@ //// [contextualTypeWithUnionTypeIndexSignatures.ts] +//When used as a contextual type, a union type U has those members that are present in any of +// its constituent types, with types that are unions of the respective members in the constituent types. // When an object literal is contextually typed by a type that includes a string index signature, // the resulting type of the object literal includes a string index signature with the union type of // the types of the properties declared in the object literal, or the Undefined type if the object literal diff --git a/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeMembers.1.normal.js b/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeMembers.1.normal.js index 65958d545259..830f636f4b51 100644 --- a/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeMembers.1.normal.js +++ b/crates/swc/tests/tsc-references/contextualTypeWithUnionTypeMembers.1.normal.js @@ -1,4 +1,6 @@ //// [contextualTypeWithUnionTypeMembers.ts] +//When used as a contextual type, a union type U has those members that are present in any of +// its constituent types, with types that are unions of the respective members in the constituent types. // Let S be the set of types in U that has a property P. // If S is not empty, U has a property P of a union type of the types of P from each type in S. var i1; diff --git a/crates/swc/tests/tsc-references/controlFlowAssignmentPatternOrder.1.normal.js b/crates/swc/tests/tsc-references/controlFlowAssignmentPatternOrder.1.normal.js index db4b901b5911..cb5a762079c8 100644 --- a/crates/swc/tests/tsc-references/controlFlowAssignmentPatternOrder.1.normal.js +++ b/crates/swc/tests/tsc-references/controlFlowAssignmentPatternOrder.1.normal.js @@ -1,4 +1,5 @@ //// [controlFlowAssignmentPatternOrder.ts] +// https://github.com/microsoft/TypeScript/pull/41094#issuecomment-716044363 { let a = 0; let b; diff --git a/crates/swc/tests/tsc-references/controlFlowOptionalChain.1.normal.js b/crates/swc/tests/tsc-references/controlFlowOptionalChain.1.normal.js index c6f5d9de611c..10629cbf9c0d 100644 --- a/crates/swc/tests/tsc-references/controlFlowOptionalChain.1.normal.js +++ b/crates/swc/tests/tsc-references/controlFlowOptionalChain.1.normal.js @@ -1,4 +1,5 @@ //// [controlFlowOptionalChain.ts] +// assignments in shortcutting chain import { _ as _instanceof } from "@swc/helpers/_/_instanceof"; import { _ as _type_of } from "@swc/helpers/_/_type_of"; var _o4_x, _o4_x1, _o5_x_y_z, _o5_x, _o5_x1, _o5_x2, _o5_x_y_z1, _o5_x3, _arr_i; diff --git a/crates/swc/tests/tsc-references/covariantCallbacks.1.normal.js b/crates/swc/tests/tsc-references/covariantCallbacks.1.normal.js index cdad211941ad..7dca0c446054 100644 --- a/crates/swc/tests/tsc-references/covariantCallbacks.1.normal.js +++ b/crates/swc/tests/tsc-references/covariantCallbacks.1.normal.js @@ -1,4 +1,5 @@ //// [covariantCallbacks.ts] +// Test that callback parameters are related covariantly function f1(a, b) { a = b; b = a; // Error diff --git a/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment4.1.normal.js b/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment4.1.normal.js index 87f5961d6933..fc3b33ff057b 100644 --- a/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment4.1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment4.1.normal.js @@ -1,3 +1,4 @@ //// [destructuringArrayBindingPatternAndAssignment4.ts] +// #35497 import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; var _data = _sliced_to_array(data, 1), value = _data[0]; // Error diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.1.normal.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.1.normal.js index af400e707263..9a1d3df98bc1 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.1.normal.js @@ -1,4 +1,8 @@ //// [destructuringParameterDeclaration3ES5.ts] +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. +// RestParameter: +// ... Identifier TypeAnnotation(opt) function a1(...x) {} function a2(...a) {} function a3(...a) {} diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.1.normal.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.1.normal.js index ab8e0843ff84..3a2e18f2b27e 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.1.normal.js @@ -1,4 +1,8 @@ //// [destructuringParameterDeclaration3ES5iterable.ts] +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. +// RestParameter: +// ... Identifier TypeAnnotation(opt) import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; import { _ as _to_array } from "@swc/helpers/_/_to_array"; import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array"; diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.1.normal.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.1.normal.js index a11155b9a857..a9efe13fcfea 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.1.normal.js @@ -1,4 +1,8 @@ //// [destructuringParameterDeclaration3ES6.ts] +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. +// RestParameter: +// ... Identifier TypeAnnotation(opt) function a1(...x) {} function a2(...a) {} function a3(...a) {} diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration5.1.normal.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration5.1.normal.js index 6102b8d7b6f4..7254975d30e7 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration5.1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration5.1.normal.js @@ -1,4 +1,5 @@ //// [destructuringParameterDeclaration5.ts] +// Parameter Declaration with generic import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/directDependenceBetweenTypeAliases.1.normal.js b/crates/swc/tests/tsc-references/directDependenceBetweenTypeAliases.1.normal.js index c5decd1e9a78..748ef9be3791 100644 --- a/crates/swc/tests/tsc-references/directDependenceBetweenTypeAliases.1.normal.js +++ b/crates/swc/tests/tsc-references/directDependenceBetweenTypeAliases.1.normal.js @@ -1,4 +1,6 @@ //// [directDependenceBetweenTypeAliases.ts] +// It is an error for the type specified in a type alias to depend on that type alias +// A type alias directly depends on the type it aliases. import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var C = function C() { "use strict"; diff --git a/crates/swc/tests/tsc-references/discriminatedUnionInference.1.normal.js b/crates/swc/tests/tsc-references/discriminatedUnionInference.1.normal.js index fb3d1f268572..2a683c85940b 100644 --- a/crates/swc/tests/tsc-references/discriminatedUnionInference.1.normal.js +++ b/crates/swc/tests/tsc-references/discriminatedUnionInference.1.normal.js @@ -1,4 +1,5 @@ //// [discriminatedUnionInference.ts] +// Repro from #28862 var x1 = foo({ kind: 'a', data: 42 diff --git a/crates/swc/tests/tsc-references/discriminatedUnionTypes3.1.normal.js b/crates/swc/tests/tsc-references/discriminatedUnionTypes3.1.normal.js index d1d6d712aa90..96b88d19ceb9 100644 --- a/crates/swc/tests/tsc-references/discriminatedUnionTypes3.1.normal.js +++ b/crates/swc/tests/tsc-references/discriminatedUnionTypes3.1.normal.js @@ -1,4 +1,5 @@ //// [discriminatedUnionTypes3.ts] +// Repro from #44435 var example = {}; if (example.err === undefined) { example.property; // true diff --git a/crates/swc/tests/tsc-references/duplicateNumericIndexers.1.normal.js b/crates/swc/tests/tsc-references/duplicateNumericIndexers.1.normal.js index ff1dc30af29c..cef2dfe0592a 100644 --- a/crates/swc/tests/tsc-references/duplicateNumericIndexers.1.normal.js +++ b/crates/swc/tests/tsc-references/duplicateNumericIndexers.1.normal.js @@ -1,4 +1,5 @@ //// [duplicateNumericIndexers.ts] +// it is an error to have duplicate index signatures of the same kind in a type import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var C = function C() { "use strict"; diff --git a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault.1.normal.js index 404db8a617b3..375291d8d70b 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault.1.normal.js +++ b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault.1.normal.js @@ -1,4 +1,5 @@ //// [main.ts] +// https://github.com/microsoft/TypeScript/issues/39149 "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/tsc-references/functionExpressionContextualTyping3.1.normal.js b/crates/swc/tests/tsc-references/functionExpressionContextualTyping3.1.normal.js index 08ef6ff8cad9..094b88e23f21 100644 --- a/crates/swc/tests/tsc-references/functionExpressionContextualTyping3.1.normal.js +++ b/crates/swc/tests/tsc-references/functionExpressionContextualTyping3.1.normal.js @@ -1,4 +1,5 @@ //// [functionExpressionContextualTyping3.ts] +// #31114 f(function(a) { return ""; }); diff --git a/crates/swc/tests/tsc-references/genericRestArity.1.normal.js b/crates/swc/tests/tsc-references/genericRestArity.1.normal.js index c92b508a4d06..a1c1babb3b18 100644 --- a/crates/swc/tests/tsc-references/genericRestArity.1.normal.js +++ b/crates/swc/tests/tsc-references/genericRestArity.1.normal.js @@ -1,4 +1,5 @@ //// [genericRestArity.ts] +// Repro from #25559 call(function(x, y) { return x + y; }); diff --git a/crates/swc/tests/tsc-references/genericRestArityStrict.1.normal.js b/crates/swc/tests/tsc-references/genericRestArityStrict.1.normal.js index 8bae5afdd2a1..e97caae44a95 100644 --- a/crates/swc/tests/tsc-references/genericRestArityStrict.1.normal.js +++ b/crates/swc/tests/tsc-references/genericRestArityStrict.1.normal.js @@ -1,4 +1,5 @@ //// [genericRestArityStrict.ts] +// Repro from #25559 call(function(x, y) { return x + y; }); diff --git a/crates/swc/tests/tsc-references/identicalCallSignatures.1.normal.js b/crates/swc/tests/tsc-references/identicalCallSignatures.1.normal.js index 6deb200eb7b3..46708f438710 100644 --- a/crates/swc/tests/tsc-references/identicalCallSignatures.1.normal.js +++ b/crates/swc/tests/tsc-references/identicalCallSignatures.1.normal.js @@ -1,2 +1,4 @@ //// [identicalCallSignatures.ts] +// Each pair of call signatures in these types have a duplicate signature error. +// Identical call signatures should generate an error. var a; diff --git a/crates/swc/tests/tsc-references/importCallExpressionInAMD2.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInAMD2.1.normal.js index b7e02adc947b..df23af1a5a93 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInAMD2.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInAMD2.1.normal.js @@ -20,6 +20,7 @@ define([ } }); //// [2.ts] +// We use Promise for now as there is no way to specify shape of module object define([ "require", "exports", @@ -29,7 +30,6 @@ define([ Object.defineProperty(exports, "__esModule", { value: true }); - // We use Promise for now as there is no way to specify shape of module object function foo(x) { x.then((value)=>{ let b = new value.B(); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInSystem2.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInSystem2.1.normal.js index 4e3dc15ca906..8187b121a81c 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInSystem2.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInSystem2.1.normal.js @@ -15,9 +15,9 @@ System.register([], function(_export, _context) { }; }); //// [2.ts] +// We use Promise for now as there is no way to specify shape of module object System.register([], function(_export, _context) { "use strict"; - // We use Promise for now as there is no way to specify shape of module object function foo(x) { x.then((value)=>{ let b = new value.B(); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInUMD2.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInUMD2.1.normal.js index 0b47662fa7dc..b6abf50b8042 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInUMD2.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInUMD2.1.normal.js @@ -23,6 +23,7 @@ } }); //// [2.ts] +// We use Promise for now as there is no way to specify shape of module object (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@swc/helpers/_/_interop_require_wildcard")); else if (typeof define === "function" && define.amd) define([ @@ -35,7 +36,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); - // We use Promise for now as there is no way to specify shape of module object function foo(x) { x.then((value)=>{ let b = new value.B(); diff --git a/crates/swc/tests/tsc-references/importCallExpressionInUMD5.1.normal.js b/crates/swc/tests/tsc-references/importCallExpressionInUMD5.1.normal.js index 76ad02ed328e..a25eba1a55a9 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionInUMD5.1.normal.js +++ b/crates/swc/tests/tsc-references/importCallExpressionInUMD5.1.normal.js @@ -21,6 +21,7 @@ } }); //// [1.ts] +// https://github.com/microsoft/TypeScript/issues/36780 (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@swc/helpers/_/_async_to_generator"), require("@swc/helpers/_/_interop_require_wildcard")); else if (typeof define === "function" && define.amd) define([ @@ -34,7 +35,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); - // https://github.com/microsoft/TypeScript/issues/36780 function func() { return _async_to_generator._(function*() { const packageName = '.'; diff --git a/crates/swc/tests/tsc-references/independentPropertyVariance.1.normal.js b/crates/swc/tests/tsc-references/independentPropertyVariance.1.normal.js index b516c07d1109..917b50ff613a 100644 --- a/crates/swc/tests/tsc-references/independentPropertyVariance.1.normal.js +++ b/crates/swc/tests/tsc-references/independentPropertyVariance.1.normal.js @@ -1,2 +1,3 @@ //// [independentPropertyVariance.ts] +// Verify that properties can vary independently in comparable relationship x === y; diff --git a/crates/swc/tests/tsc-references/inferTypes2.1.normal.js b/crates/swc/tests/tsc-references/inferTypes2.1.normal.js index f551878b8624..95d821796279 100644 --- a/crates/swc/tests/tsc-references/inferTypes2.1.normal.js +++ b/crates/swc/tests/tsc-references/inferTypes2.1.normal.js @@ -1,4 +1,5 @@ //// [inferTypes2.ts] +// Repros from #22755 export function bar(obj) { return foo(obj); } diff --git a/crates/swc/tests/tsc-references/inferTypesWithExtends1.1.normal.js b/crates/swc/tests/tsc-references/inferTypesWithExtends1.1.normal.js index 33bb2c2b457a..720eebfe002c 100644 --- a/crates/swc/tests/tsc-references/inferTypesWithExtends1.1.normal.js +++ b/crates/swc/tests/tsc-references/inferTypesWithExtends1.1.normal.js @@ -1,4 +1,5 @@ //// [inferTypesWithExtends1.ts] +// infer to tuple element function f1() { return x1; } diff --git a/crates/swc/tests/tsc-references/infiniteExpansionThroughInstantiation.1.normal.js b/crates/swc/tests/tsc-references/infiniteExpansionThroughInstantiation.1.normal.js index c11800006e5e..87b1d8dcf565 100644 --- a/crates/swc/tests/tsc-references/infiniteExpansionThroughInstantiation.1.normal.js +++ b/crates/swc/tests/tsc-references/infiniteExpansionThroughInstantiation.1.normal.js @@ -1,4 +1,5 @@ //// [infiniteExpansionThroughInstantiation.ts] +// instantiating a derived type can cause an infinitely expanding type reference to be generated var list; var ownerList; list = ownerList; diff --git a/crates/swc/tests/tsc-references/intersectionIncludingPropFromGlobalAugmentation.1.normal.js b/crates/swc/tests/tsc-references/intersectionIncludingPropFromGlobalAugmentation.1.normal.js index 5ced1f6e0904..d2a247e33028 100644 --- a/crates/swc/tests/tsc-references/intersectionIncludingPropFromGlobalAugmentation.1.normal.js +++ b/crates/swc/tests/tsc-references/intersectionIncludingPropFromGlobalAugmentation.1.normal.js @@ -1,4 +1,5 @@ //// [intersectionIncludingPropFromGlobalAugmentation.ts] +// repro from https://github.com/microsoft/TypeScript/issues/54345 import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; var target = _object_spread({}, source); var toString = target.toString; diff --git a/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.1.normal.js b/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.1.normal.js index d865b0c7c379..7f4494dc79bf 100644 --- a/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.1.normal.js +++ b/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.1.normal.js @@ -1,4 +1,5 @@ //// [intersectionOfUnionOfUnitTypes.ts] +// @strict var x0; // 'a' | 'b' | 'c' var x1; // 'b' | 'c' var x2; // 'c' diff --git a/crates/swc/tests/tsc-references/intersectionTypeInference3.1.normal.js b/crates/swc/tests/tsc-references/intersectionTypeInference3.1.normal.js index 10ec4d11dce9..e4f455596a24 100644 --- a/crates/swc/tests/tsc-references/intersectionTypeInference3.1.normal.js +++ b/crates/swc/tests/tsc-references/intersectionTypeInference3.1.normal.js @@ -1,3 +1,4 @@ //// [intersectionTypeInference3.ts] +// Repro from #19682 const c1 = Array.from(a).concat(Array.from(b)); const c2 = from(); diff --git a/crates/swc/tests/tsc-references/intersectionTypeMembers.1.normal.js b/crates/swc/tests/tsc-references/intersectionTypeMembers.1.normal.js index 8935adb448c3..218c470a4afe 100644 --- a/crates/swc/tests/tsc-references/intersectionTypeMembers.1.normal.js +++ b/crates/swc/tests/tsc-references/intersectionTypeMembers.1.normal.js @@ -1,4 +1,6 @@ //// [intersectionTypeMembers.ts] +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types var abc; abc.a = "hello"; abc.b = "hello"; diff --git a/crates/swc/tests/tsc-references/intersectionTypeOverloading.1.normal.js b/crates/swc/tests/tsc-references/intersectionTypeOverloading.1.normal.js index 10009f7ed5db..ac492061acf9 100644 --- a/crates/swc/tests/tsc-references/intersectionTypeOverloading.1.normal.js +++ b/crates/swc/tests/tsc-references/intersectionTypeOverloading.1.normal.js @@ -1,4 +1,6 @@ //// [intersectionTypeOverloading.ts] +// Check that order is preserved in intersection types for purposes of +// overload resolution var fg; var gf; var x = fg("abc"); diff --git a/crates/swc/tests/tsc-references/intersectionsAndEmptyObjects.1.normal.js b/crates/swc/tests/tsc-references/intersectionsAndEmptyObjects.1.normal.js index 4593ab42787d..e246924d8c03 100644 --- a/crates/swc/tests/tsc-references/intersectionsAndEmptyObjects.1.normal.js +++ b/crates/swc/tests/tsc-references/intersectionsAndEmptyObjects.1.normal.js @@ -1,4 +1,6 @@ //// [intersectionsAndEmptyObjects.ts] +// Empty object type literals are removed from intersections types +// that contain other object types "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/tsc-references/intraExpressionInferences.1.normal.js b/crates/swc/tests/tsc-references/intraExpressionInferences.1.normal.js index 04261a7a75fc..246112eec8e0 100644 --- a/crates/swc/tests/tsc-references/intraExpressionInferences.1.normal.js +++ b/crates/swc/tests/tsc-references/intraExpressionInferences.1.normal.js @@ -1,4 +1,5 @@ //// [intraExpressionInferences.ts] +// Repros from #47599 import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; callIt({ diff --git a/crates/swc/tests/tsc-references/intraExpressionInferencesJsx.1.normal.js b/crates/swc/tests/tsc-references/intraExpressionInferencesJsx.1.normal.js index d3711478e92c..0f1df489db4b 100644 --- a/crates/swc/tests/tsc-references/intraExpressionInferencesJsx.1.normal.js +++ b/crates/swc/tests/tsc-references/intraExpressionInferencesJsx.1.normal.js @@ -1,4 +1,6 @@ //// [intraExpressionInferencesJsx.tsx] +/// +// repro from #52798 var Component = function(param) { var animations = param.animations, style = param.style; return /*#__PURE__*/ React.createElement(React.Fragment, null); diff --git a/crates/swc/tests/tsc-references/jsDeclarationsDefaultsErr.1.normal.js b/crates/swc/tests/tsc-references/jsDeclarationsDefaultsErr.1.normal.js index 27ea5c452957..a6741f7a016e 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsDefaultsErr.1.normal.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsDefaultsErr.1.normal.js @@ -11,6 +11,7 @@ export default Cls; /** * @typedef {string | number} default */ //// [index2.js] +// merge type alias and class (error message improvement needed, see #32368) import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var C = function C() { "use strict"; diff --git a/crates/swc/tests/tsc-references/jsDeclarationsImportTypeBundled.1.normal.js b/crates/swc/tests/tsc-references/jsDeclarationsImportTypeBundled.1.normal.js index 64c5655e17c7..e9d08cd0b223 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsImportTypeBundled.1.normal.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsImportTypeBundled.1.normal.js @@ -1,23 +1,23 @@ //// [folder/mod1.js] -define([ - "require" -], function(require) { - "use strict"; - /** +/** * @typedef {{x: number}} Item */ /** * @type {Item}; - */ var x = { + */ define([ + "require" +], function(require) { + "use strict"; + var x = { x: 12 }; module.exports = x; }); //// [index.js] -define([ +/** @type {(typeof import("./folder/mod1"))[]} */ define([ "require" ], function(require) { "use strict"; - /** @type {(typeof import("./folder/mod1"))[]} */ var items = [ + var items = [ { x: 12 } diff --git a/crates/swc/tests/tsc-references/jsDeclarationsInterfaces.1.normal.js b/crates/swc/tests/tsc-references/jsDeclarationsInterfaces.1.normal.js index 6e5ef12dc3e9..9074e11ed22c 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsInterfaces.1.normal.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsInterfaces.1.normal.js @@ -1,2 +1,4 @@ //// [index.js] +// Pretty much all of this should be an error, (since interfaces are forbidden in js), +// but we should be able to synthesize declarations from the symbols regardless export { }; diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImportPragma.1.normal.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImportPragma.1.normal.js index 6ab2886f8f4f..1fe7efb661c3 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImportPragma.1.normal.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImportPragma.1.normal.js @@ -15,7 +15,8 @@ var _jsxruntime = require("preact/jsx-runtime"); ] }); //// [react.tsx] -"use strict"; +/// +/* @jsxImportSource react */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImportPragma.1.normal.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImportPragma.1.normal.js index b2cdf7217e2d..8ccd61ff9f17 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImportPragma.1.normal.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImportPragma.1.normal.js @@ -18,7 +18,8 @@ var b = /*#__PURE__*/ (0, _preact.createElement)("div", _object_spread_props._(_ key: "bar" }), "text"); //// [react.tsx] -"use strict"; +/// +/* @jsxImportSource react */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformNestedSelfClosingChild.1.normal.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformNestedSelfClosingChild.1.normal.js index a9c31806f572..a4d9d693412f 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformNestedSelfClosingChild.1.normal.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformNestedSelfClosingChild.1.normal.js @@ -1,4 +1,5 @@ //// [jsxJsxsCjsTransformNestedSelfClosingChild.tsx] +/// "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/tsc-references/keyofInferenceLowerPriorityThanReturn.1.normal.js b/crates/swc/tests/tsc-references/keyofInferenceLowerPriorityThanReturn.1.normal.js index 40a11e8d1ee2..dabd170a1e11 100644 --- a/crates/swc/tests/tsc-references/keyofInferenceLowerPriorityThanReturn.1.normal.js +++ b/crates/swc/tests/tsc-references/keyofInferenceLowerPriorityThanReturn.1.normal.js @@ -1,4 +1,5 @@ //// [keyofInferenceLowerPriorityThanReturn.ts] +// #22736 var bookTable = null; function insertOnConflictDoNothing(_table, _conflictTarget) { throw new Error(); diff --git a/crates/swc/tests/tsc-references/libReferenceDeclarationEmit.1.normal.js b/crates/swc/tests/tsc-references/libReferenceDeclarationEmit.1.normal.js index f4c1b3493c44..25d23d45f6b1 100644 --- a/crates/swc/tests/tsc-references/libReferenceDeclarationEmit.1.normal.js +++ b/crates/swc/tests/tsc-references/libReferenceDeclarationEmit.1.normal.js @@ -1,9 +1,11 @@ //// [file1.ts] +/// "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); //// [file2.ts] +/// "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/tsc-references/libReferenceDeclarationEmitBundle.1.normal.js b/crates/swc/tests/tsc-references/libReferenceDeclarationEmitBundle.1.normal.js index de80afc0e73f..d5b8c7c2721a 100644 --- a/crates/swc/tests/tsc-references/libReferenceDeclarationEmitBundle.1.normal.js +++ b/crates/swc/tests/tsc-references/libReferenceDeclarationEmitBundle.1.normal.js @@ -1,4 +1,5 @@ //// [file1.ts] +/// define([ "require", "exports" @@ -9,6 +10,7 @@ define([ }); }); //// [file2.ts] +/// define([ "require", "exports" diff --git a/crates/swc/tests/tsc-references/libReferenceNoLib.1.normal.js b/crates/swc/tests/tsc-references/libReferenceNoLib.1.normal.js index 75946f30da13..f2883d9daca2 100644 --- a/crates/swc/tests/tsc-references/libReferenceNoLib.1.normal.js +++ b/crates/swc/tests/tsc-references/libReferenceNoLib.1.normal.js @@ -1,8 +1,10 @@ //// [libReferenceNoLib.ts] +// Test that passing noLib disables resolution. "use strict"; //// [fakelib.ts] "use strict"; //// [file1.ts] +/// "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/tsc-references/libReferenceNoLibBundle.1.normal.js b/crates/swc/tests/tsc-references/libReferenceNoLibBundle.1.normal.js index bfaaba0de396..18f607fe3632 100644 --- a/crates/swc/tests/tsc-references/libReferenceNoLibBundle.1.normal.js +++ b/crates/swc/tests/tsc-references/libReferenceNoLibBundle.1.normal.js @@ -1,4 +1,5 @@ //// [libReferenceNoLibBundle.ts] +// Test that passing noLib disables resolution. define([ "require" ], function(require) { @@ -11,6 +12,7 @@ define([ "use strict"; }); //// [file1.ts] +/// define([ "require", "exports" diff --git a/crates/swc/tests/tsc-references/mappedTypeAsClauseRelationships.1.normal.js b/crates/swc/tests/tsc-references/mappedTypeAsClauseRelationships.1.normal.js index cf340fa3c7f9..8045b4b7284f 100644 --- a/crates/swc/tests/tsc-references/mappedTypeAsClauseRelationships.1.normal.js +++ b/crates/swc/tests/tsc-references/mappedTypeAsClauseRelationships.1.normal.js @@ -1,4 +1,5 @@ //// [mappedTypeAsClauseRelationships.ts] +// From original issue #45212: function fun(val) { var x = val; // Ok var y = val; // Error diff --git a/crates/swc/tests/tsc-references/mappedTypeAsClauses.1.normal.js b/crates/swc/tests/tsc-references/mappedTypeAsClauses.1.normal.js index bdc80b22d40b..11c8d2d421f1 100644 --- a/crates/swc/tests/tsc-references/mappedTypeAsClauses.1.normal.js +++ b/crates/swc/tests/tsc-references/mappedTypeAsClauses.1.normal.js @@ -1,4 +1,5 @@ //// [mappedTypeAsClauses.ts] +// Mapped type 'as N' clauses var e1 = { foo: "hello" }; diff --git a/crates/swc/tests/tsc-references/mappedTypeInferenceErrors.1.normal.js b/crates/swc/tests/tsc-references/mappedTypeInferenceErrors.1.normal.js index c366a9ca5f15..ea3fadc258cd 100644 --- a/crates/swc/tests/tsc-references/mappedTypeInferenceErrors.1.normal.js +++ b/crates/swc/tests/tsc-references/mappedTypeInferenceErrors.1.normal.js @@ -1,4 +1,5 @@ //// [mappedTypeInferenceErrors.ts] +// Repro from #19316 foo({ props: { x: 10, diff --git a/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.1.normal.js b/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.1.normal.js index 51feafbc93c6..0c068df05270 100644 --- a/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.1.normal.js +++ b/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.1.normal.js @@ -1,4 +1,5 @@ //// [mappedTypesGenericTuples2.ts] +// https://github.com/microsoft/TypeScript/issues/57389 import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array"; Promise.all([ getT() diff --git a/crates/swc/tests/tsc-references/mergeThreeInterfaces.1.normal.js b/crates/swc/tests/tsc-references/mergeThreeInterfaces.1.normal.js index 55bb07629b43..925b25401a6a 100644 --- a/crates/swc/tests/tsc-references/mergeThreeInterfaces.1.normal.js +++ b/crates/swc/tests/tsc-references/mergeThreeInterfaces.1.normal.js @@ -1,4 +1,6 @@ //// [mergeThreeInterfaces.ts] +// interfaces with the same root module should merge +// basic case var a; var r1 = a.foo; var r2 = a.bar; diff --git a/crates/swc/tests/tsc-references/mergeTwoInterfaces.1.normal.js b/crates/swc/tests/tsc-references/mergeTwoInterfaces.1.normal.js index b7a3309d0834..44312c8764aa 100644 --- a/crates/swc/tests/tsc-references/mergeTwoInterfaces.1.normal.js +++ b/crates/swc/tests/tsc-references/mergeTwoInterfaces.1.normal.js @@ -1,4 +1,6 @@ //// [mergeTwoInterfaces.ts] +// two interfaces with the same root module should merge +// basic case var a; var r1 = a.foo; var r2 = a.bar; diff --git a/crates/swc/tests/tsc-references/mergedInterfacesWithIndexers.1.normal.js b/crates/swc/tests/tsc-references/mergedInterfacesWithIndexers.1.normal.js index 16d32d1c72df..d51b5d7f3dc9 100644 --- a/crates/swc/tests/tsc-references/mergedInterfacesWithIndexers.1.normal.js +++ b/crates/swc/tests/tsc-references/mergedInterfacesWithIndexers.1.normal.js @@ -1,4 +1,5 @@ //// [mergedInterfacesWithIndexers.ts] +// indexers should behave like other members when merging interface declarations var a; var r = a[1]; var r2 = a['1']; diff --git a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension1.1.normal.js b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension1.1.normal.js index ab455c5e7251..6c44e6e1fc24 100644 --- a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension1.1.normal.js +++ b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension1.1.normal.js @@ -4,4 +4,5 @@ export function foo() { return ""; } //// [/src/bar.mts] +// Extensionless relative path ES import in an ES module export { }; // should error, ask for extension, no extension suggestion diff --git a/crates/swc/tests/tsc-references/noInfer.1.normal.js b/crates/swc/tests/tsc-references/noInfer.1.normal.js index 5b9214288520..dd8eb7c33cb1 100644 --- a/crates/swc/tests/tsc-references/noInfer.1.normal.js +++ b/crates/swc/tests/tsc-references/noInfer.1.normal.js @@ -1,4 +1,5 @@ //// [noInfer.ts] +// NoInfer is erased for primitives import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; foo1('foo', 'foo'); // ok diff --git a/crates/swc/tests/tsc-references/nonPrimitiveAndEmptyObject.1.normal.js b/crates/swc/tests/tsc-references/nonPrimitiveAndEmptyObject.1.normal.js index 43605e69f31e..d016e0c51dd2 100644 --- a/crates/swc/tests/tsc-references/nonPrimitiveAndEmptyObject.1.normal.js +++ b/crates/swc/tests/tsc-references/nonPrimitiveAndEmptyObject.1.normal.js @@ -1,4 +1,5 @@ //// [nonPrimitiveAndEmptyObject.ts] +// Repro from #49480 var _foo_fooProps = foo.fooProps, fooProps = _foo_fooProps === void 0 ? {} : _foo_fooProps; fooProps.barProp; export { }; diff --git a/crates/swc/tests/tsc-references/nonPrimitiveAndTypeVariables.1.normal.js b/crates/swc/tests/tsc-references/nonPrimitiveAndTypeVariables.1.normal.js index 3bfe989b831e..84cee14f9a69 100644 --- a/crates/swc/tests/tsc-references/nonPrimitiveAndTypeVariables.1.normal.js +++ b/crates/swc/tests/tsc-references/nonPrimitiveAndTypeVariables.1.normal.js @@ -1,4 +1,5 @@ //// [nonPrimitiveAndTypeVariables.ts] +// Repros from #23800 var a = { a: 0 }; diff --git a/crates/swc/tests/tsc-references/numericIndexerConstrainsPropertyDeclarations.1.normal.js b/crates/swc/tests/tsc-references/numericIndexerConstrainsPropertyDeclarations.1.normal.js index 9b651f95d647..ab5a4a9dc52c 100644 --- a/crates/swc/tests/tsc-references/numericIndexerConstrainsPropertyDeclarations.1.normal.js +++ b/crates/swc/tests/tsc-references/numericIndexerConstrainsPropertyDeclarations.1.normal.js @@ -1,4 +1,5 @@ //// [numericIndexerConstrainsPropertyDeclarations.ts] +// String indexer types constrain the types of named properties in their containing type import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; var C = /*#__PURE__*/ function() { diff --git a/crates/swc/tests/tsc-references/objectLiteralContextualTyping.1.normal.js b/crates/swc/tests/tsc-references/objectLiteralContextualTyping.1.normal.js index 975edc02a7c2..1c282f426764 100644 --- a/crates/swc/tests/tsc-references/objectLiteralContextualTyping.1.normal.js +++ b/crates/swc/tests/tsc-references/objectLiteralContextualTyping.1.normal.js @@ -1,4 +1,8 @@ //// [objectLiteralContextualTyping.ts] +// In a contextually typed object literal, each property value expression is contextually typed by +// the type of the property with a matching name in the contextual type, if any, or otherwise +// for a numerically named property, the numeric index type of the contextual type, if any, or otherwise +// the string index type of the contextual type, if any. var x = foo({ name: "Sprocket" }); diff --git a/crates/swc/tests/tsc-references/objectRest2.1.normal.js b/crates/swc/tests/tsc-references/objectRest2.1.normal.js index 7ca2de130bc9..c3da7a6d5d19 100644 --- a/crates/swc/tests/tsc-references/objectRest2.1.normal.js +++ b/crates/swc/tests/tsc-references/objectRest2.1.normal.js @@ -1,4 +1,5 @@ //// [objectRest2.ts] +// test for #12203 import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; function rootConnection(name) { diff --git a/crates/swc/tests/tsc-references/objectRestReadonly.1.normal.js b/crates/swc/tests/tsc-references/objectRestReadonly.1.normal.js index fd73e93d0a6b..7066801ee36b 100644 --- a/crates/swc/tests/tsc-references/objectRestReadonly.1.normal.js +++ b/crates/swc/tests/tsc-references/objectRestReadonly.1.normal.js @@ -1,4 +1,5 @@ //// [objectRestReadonly.ts] +// #23734 import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties"; var obj = { foo: 'bar', diff --git a/crates/swc/tests/tsc-references/objectTypeWithCallSignatureAppearsToBeFunctionType.1.normal.js b/crates/swc/tests/tsc-references/objectTypeWithCallSignatureAppearsToBeFunctionType.1.normal.js index 352ab2bc2670..059e48fb517e 100644 --- a/crates/swc/tests/tsc-references/objectTypeWithCallSignatureAppearsToBeFunctionType.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypeWithCallSignatureAppearsToBeFunctionType.1.normal.js @@ -1,4 +1,6 @@ //// [objectTypeWithCallSignatureAppearsToBeFunctionType.ts] +// objects with call signatures should be permitted where function types are expected +// no errors expected below var i; var r2 = i(); var r2b = i.apply; diff --git a/crates/swc/tests/tsc-references/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.1.normal.js b/crates/swc/tests/tsc-references/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.1.normal.js index a1741d05efa6..bdfa706bb342 100644 --- a/crates/swc/tests/tsc-references/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.1.normal.js @@ -1,4 +1,6 @@ //// [objectTypeWithCallSignatureHidingMembersOfExtendedFunction.ts] +// object types with call signatures can override members of Function +// no errors expected below var i; var r1 = i.apply; var r1b = i.call; diff --git a/crates/swc/tests/tsc-references/objectTypeWithCallSignatureHidingMembersOfFunction.1.normal.js b/crates/swc/tests/tsc-references/objectTypeWithCallSignatureHidingMembersOfFunction.1.normal.js index fb512113f042..a9ffa1befa0e 100644 --- a/crates/swc/tests/tsc-references/objectTypeWithCallSignatureHidingMembersOfFunction.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypeWithCallSignatureHidingMembersOfFunction.1.normal.js @@ -1,4 +1,6 @@ //// [objectTypeWithCallSignatureHidingMembersOfFunction.ts] +// object types with call signatures can override members of Function +// no errors expected below var i; var r1 = i.apply; var r1b = i.call; diff --git a/crates/swc/tests/tsc-references/objectTypeWithConstructSignatureAppearsToBeFunctionType.1.normal.js b/crates/swc/tests/tsc-references/objectTypeWithConstructSignatureAppearsToBeFunctionType.1.normal.js index a12906718ecf..f0c4ba94b667 100644 --- a/crates/swc/tests/tsc-references/objectTypeWithConstructSignatureAppearsToBeFunctionType.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypeWithConstructSignatureAppearsToBeFunctionType.1.normal.js @@ -1,4 +1,5 @@ //// [objectTypeWithConstructSignatureAppearsToBeFunctionType.ts] +// no errors expected below var i; var r2 = i(); var r2b = new i(); diff --git a/crates/swc/tests/tsc-references/objectTypeWithStringAndNumberIndexSignatureToAny.1.normal.js b/crates/swc/tests/tsc-references/objectTypeWithStringAndNumberIndexSignatureToAny.1.normal.js index 9cb85c1c04dc..01efe8f1bd4b 100644 --- a/crates/swc/tests/tsc-references/objectTypeWithStringAndNumberIndexSignatureToAny.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypeWithStringAndNumberIndexSignatureToAny.1.normal.js @@ -1,4 +1,22 @@ //// [objectTypeWithStringAndNumberIndexSignatureToAny.ts] +// When checking compatibility between two types, +// TypeScript should not require an index signature if +// the target side index signature maps to `any` *and* +// the target side has *any* string index signature to `any`. +// +// So an index signature like in +// +// { [x: number]: any } +// +// is still required of a source type, but neither index signature in +// +// { [x: number]: any, [x: string]: any; } +// +// should be required; *however*, the number index signature in +// +// { [x: number]: number, [x: string]: any; } +// +// should always be required. function f1(sToAny, nToAny, bothToAny, someObj) { sToAny = nToAny; sToAny = bothToAny; diff --git a/crates/swc/tests/tsc-references/objectTypeWithStringIndexerHidingObjectIndexer.1.normal.js b/crates/swc/tests/tsc-references/objectTypeWithStringIndexerHidingObjectIndexer.1.normal.js index d5d566c25d7e..723ab8e3e101 100644 --- a/crates/swc/tests/tsc-references/objectTypeWithStringIndexerHidingObjectIndexer.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypeWithStringIndexerHidingObjectIndexer.1.normal.js @@ -1,4 +1,6 @@ //// [objectTypeWithStringIndexerHidingObjectIndexer.ts] +// object types can define string indexers that are more specific than the default 'any' that would be returned +// no errors expected below import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var o = {}; var r = o['']; // should be Object diff --git a/crates/swc/tests/tsc-references/objectTypesIdentityWithCallSignatures3.1.normal.js b/crates/swc/tests/tsc-references/objectTypesIdentityWithCallSignatures3.1.normal.js index ea1b949d17b9..5e1af0501252 100644 --- a/crates/swc/tests/tsc-references/objectTypesIdentityWithCallSignatures3.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypesIdentityWithCallSignatures3.1.normal.js @@ -1,4 +1,5 @@ //// [objectTypesIdentityWithCallSignatures3.ts] +// object types are identical structurally var a; function foo2(x) {} function foo3(x) {} diff --git a/crates/swc/tests/tsc-references/objectTypesIdentityWithCallSignaturesDifferingParamCounts2.1.normal.js b/crates/swc/tests/tsc-references/objectTypesIdentityWithCallSignaturesDifferingParamCounts2.1.normal.js index cf51dd2f25b2..7a8ef8f527cb 100644 --- a/crates/swc/tests/tsc-references/objectTypesIdentityWithCallSignaturesDifferingParamCounts2.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypesIdentityWithCallSignaturesDifferingParamCounts2.1.normal.js @@ -1,4 +1,5 @@ //// [objectTypesIdentityWithCallSignaturesDifferingParamCounts2.ts] +// object types are identical structurally var a; function foo2(x) {} function foo3(x) {} diff --git a/crates/swc/tests/tsc-references/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts2.1.normal.js b/crates/swc/tests/tsc-references/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts2.1.normal.js index aa30b58d16a9..8e639c9ef394 100644 --- a/crates/swc/tests/tsc-references/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts2.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts2.1.normal.js @@ -1,4 +1,5 @@ //// [objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts2.ts] +// object types are identical structurally var a; function foo1(x) {} function foo2(x) {} diff --git a/crates/swc/tests/tsc-references/optionalChainingInference.1.normal.js b/crates/swc/tests/tsc-references/optionalChainingInference.1.normal.js index e73c3006d334..d0600a4181df 100644 --- a/crates/swc/tests/tsc-references/optionalChainingInference.1.normal.js +++ b/crates/swc/tests/tsc-references/optionalChainingInference.1.normal.js @@ -1,4 +1,5 @@ //// [optionalChainingInference.ts] +// https://github.com/microsoft/TypeScript/issues/34579 var b1 = { value: su === null || su === void 0 ? void 0 : su.length }; diff --git a/crates/swc/tests/tsc-references/parenthesizedContexualTyping2.1.normal.js b/crates/swc/tests/tsc-references/parenthesizedContexualTyping2.1.normal.js index 1038feb8cce2..0e967d50c9bb 100644 --- a/crates/swc/tests/tsc-references/parenthesizedContexualTyping2.1.normal.js +++ b/crates/swc/tests/tsc-references/parenthesizedContexualTyping2.1.normal.js @@ -1,4 +1,9 @@ //// [parenthesizedContexualTyping2.ts] +// These tests ensure that in cases where it may *appear* that a value has a type, +// they actually are properly being contextually typed. The way we test this is +// that we invoke contextually typed arguments with type arguments. +// Since 'any' cannot be invoked with type arguments, we should get errors +// back if contextual typing is not taking effect. function fun() { for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){ rest[_key] = arguments[_key]; diff --git a/crates/swc/tests/tsc-references/parenthesizedContexualTyping3.1.normal.js b/crates/swc/tests/tsc-references/parenthesizedContexualTyping3.1.normal.js index 94bfa3593fed..94aa080f7f08 100644 --- a/crates/swc/tests/tsc-references/parenthesizedContexualTyping3.1.normal.js +++ b/crates/swc/tests/tsc-references/parenthesizedContexualTyping3.1.normal.js @@ -1,5 +1,8 @@ //// [parenthesizedContexualTyping3.ts] -function tempFun(tempStrs, g, x) { +// Contextual typing for parenthesized substitution expressions in tagged templates. +/** + * tempFun - Can't have fun for too long. + */ function tempFun(tempStrs, g, x) { return g(x); } var a = tempFun`${(x)=>x} ${10}`; diff --git a/crates/swc/tests/tsc-references/parserAstSpans1.1.normal.js b/crates/swc/tests/tsc-references/parserAstSpans1.1.normal.js index 3a6991722977..2c3beae11413 100644 --- a/crates/swc/tests/tsc-references/parserAstSpans1.1.normal.js +++ b/crates/swc/tests/tsc-references/parserAstSpans1.1.normal.js @@ -1,5 +1,5 @@ //// [parserAstSpans1.ts] -import { _ as _assert_this_initialized } from "@swc/helpers/_/_assert_this_initialized"; +/** i1 is interface with properties*/ import { _ as _assert_this_initialized } from "@swc/helpers/_/_assert_this_initialized"; import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; diff --git a/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.1.normal.js b/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.1.normal.js index 4b0988909cbb..1d2077f6905f 100644 --- a/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.1.normal.js +++ b/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.1.normal.js @@ -1,4 +1,5 @@ //// [parserErrorRecovery_IncompleteMemberVariable1.ts] +// Interface import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; // Module (function(Shapes) { diff --git a/crates/swc/tests/tsc-references/partiallyAnnotatedFunctionWitoutTypeParameter.1.normal.js b/crates/swc/tests/tsc-references/partiallyAnnotatedFunctionWitoutTypeParameter.1.normal.js index 425235c7d605..f66d34d79058 100644 --- a/crates/swc/tests/tsc-references/partiallyAnnotatedFunctionWitoutTypeParameter.1.normal.js +++ b/crates/swc/tests/tsc-references/partiallyAnnotatedFunctionWitoutTypeParameter.1.normal.js @@ -1,3 +1,4 @@ //// [partiallyAnnotatedFunctionWitoutTypeParameter.ts] +// simple case simple(function(a, b) {}); simple(function(a, b) {}); diff --git a/crates/swc/tests/tsc-references/partiallyNamedTuples2.1.normal.js b/crates/swc/tests/tsc-references/partiallyNamedTuples2.1.normal.js index d50f0d220ade..570951e75e9b 100644 --- a/crates/swc/tests/tsc-references/partiallyNamedTuples2.1.normal.js +++ b/crates/swc/tests/tsc-references/partiallyNamedTuples2.1.normal.js @@ -1,4 +1,5 @@ //// [partiallyNamedTuples2.ts] +// https://github.com/microsoft/TypeScript/issues/55693 var x = null; var id1 = "abc"; var matches = x.get(id1); diff --git a/crates/swc/tests/tsc-references/primtiveTypesAreIdentical.1.normal.js b/crates/swc/tests/tsc-references/primtiveTypesAreIdentical.1.normal.js index 91deb0247e6c..ec46588cb132 100644 --- a/crates/swc/tests/tsc-references/primtiveTypesAreIdentical.1.normal.js +++ b/crates/swc/tests/tsc-references/primtiveTypesAreIdentical.1.normal.js @@ -1,4 +1,5 @@ //// [primtiveTypesAreIdentical.ts] +// primitive types are identical to themselves so these overloads will all cause errors function foo1(x) {} function foo2(x) {} function foo3(x) {} diff --git a/crates/swc/tests/tsc-references/privateNameEmitHelpers.1.normal.js b/crates/swc/tests/tsc-references/privateNameEmitHelpers.1.normal.js index 1ad70259262d..92f3ddae7142 100644 --- a/crates/swc/tests/tsc-references/privateNameEmitHelpers.1.normal.js +++ b/crates/swc/tests/tsc-references/privateNameEmitHelpers.1.normal.js @@ -26,4 +26,5 @@ function set_c(v) { _class_private_field_set(this, _a, _class_private_field_get(this, _a) + v); } //// [tslib.d.ts] +// these are pre-TS4.3 versions of emit helpers, which only supported private instance fields export { }; diff --git a/crates/swc/tests/tsc-references/privateNameStaticEmitHelpers.1.normal.js b/crates/swc/tests/tsc-references/privateNameStaticEmitHelpers.1.normal.js index 419c9ca6f031..161ac89835d3 100644 --- a/crates/swc/tests/tsc-references/privateNameStaticEmitHelpers.1.normal.js +++ b/crates/swc/tests/tsc-references/privateNameStaticEmitHelpers.1.normal.js @@ -19,4 +19,5 @@ function get_c() { return _class_static_private_method_get(S, S, b).call(S); } //// [tslib.d.ts] +// these are pre-TS4.3 versions of emit helpers, which only supported private instance fields export { }; diff --git a/crates/swc/tests/tsc-references/recursiveMappedTypes.1.normal.js b/crates/swc/tests/tsc-references/recursiveMappedTypes.1.normal.js index 7dad85d03355..d41f028c8115 100644 --- a/crates/swc/tests/tsc-references/recursiveMappedTypes.1.normal.js +++ b/crates/swc/tests/tsc-references/recursiveMappedTypes.1.normal.js @@ -1,4 +1,5 @@ //// [recursiveMappedTypes.ts] +// Recursive mapped types simply appear empty function foo(arg) { return arg; } diff --git a/crates/swc/tests/tsc-references/specializedSignatureIsSubtypeOfNonSpecializedSignature.1.normal.js b/crates/swc/tests/tsc-references/specializedSignatureIsSubtypeOfNonSpecializedSignature.1.normal.js index a6a260b3632e..42136e3f7dff 100644 --- a/crates/swc/tests/tsc-references/specializedSignatureIsSubtypeOfNonSpecializedSignature.1.normal.js +++ b/crates/swc/tests/tsc-references/specializedSignatureIsSubtypeOfNonSpecializedSignature.1.normal.js @@ -1,4 +1,6 @@ //// [specializedSignatureIsSubtypeOfNonSpecializedSignature.ts] +// Specialized signatures must be a subtype of a non-specialized signature +// All the below should not be errors import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function foo(x) {} var C = /*#__PURE__*/ function() { diff --git a/crates/swc/tests/tsc-references/spreadContextualTypedBindingPattern.1.normal.js b/crates/swc/tests/tsc-references/spreadContextualTypedBindingPattern.1.normal.js index c7ec472e038d..e482bd81e100 100644 --- a/crates/swc/tests/tsc-references/spreadContextualTypedBindingPattern.1.normal.js +++ b/crates/swc/tests/tsc-references/spreadContextualTypedBindingPattern.1.normal.js @@ -1,4 +1,5 @@ //// [spreadContextualTypedBindingPattern.ts] +// #18308 import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; // [ts] Initializer provides no value for this binding element and the binding element has no default value. var _$_object_spread = _object_spread({}, bob, alice), naam = _$_object_spread.naam, age = _$_object_spread.age; diff --git a/crates/swc/tests/tsc-references/spreadDuplicate.1.normal.js b/crates/swc/tests/tsc-references/spreadDuplicate.1.normal.js index 8a09a186294e..89d2d82d5b82 100644 --- a/crates/swc/tests/tsc-references/spreadDuplicate.1.normal.js +++ b/crates/swc/tests/tsc-references/spreadDuplicate.1.normal.js @@ -1,4 +1,5 @@ //// [spreadDuplicate.ts] +// Repro from #44438 import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; var a1 = _object_spread({ a: 123 diff --git a/crates/swc/tests/tsc-references/spreadDuplicateExact.1.normal.js b/crates/swc/tests/tsc-references/spreadDuplicateExact.1.normal.js index c3a5186195f3..05c88eb3ead7 100644 --- a/crates/swc/tests/tsc-references/spreadDuplicateExact.1.normal.js +++ b/crates/swc/tests/tsc-references/spreadDuplicateExact.1.normal.js @@ -1,4 +1,5 @@ //// [spreadDuplicateExact.ts] +// Repro from #44438 import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; var a1 = _object_spread({ a: 123 diff --git a/crates/swc/tests/tsc-references/spreadNonObject1.1.normal.js b/crates/swc/tests/tsc-references/spreadNonObject1.1.normal.js index dfe90095036c..25a8eeb414e8 100644 --- a/crates/swc/tests/tsc-references/spreadNonObject1.1.normal.js +++ b/crates/swc/tests/tsc-references/spreadNonObject1.1.normal.js @@ -1,4 +1,5 @@ //// [spreadNonObject1.ts] +// https://github.com/microsoft/TypeScript/issues/45493 import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; var b = { diff --git a/crates/swc/tests/tsc-references/spreadOverwritesProperty.1.normal.js b/crates/swc/tests/tsc-references/spreadOverwritesProperty.1.normal.js index 32e56dc757a2..532b9f294fe0 100644 --- a/crates/swc/tests/tsc-references/spreadOverwritesProperty.1.normal.js +++ b/crates/swc/tests/tsc-references/spreadOverwritesProperty.1.normal.js @@ -1,4 +1,5 @@ //// [spreadOverwritesProperty.ts] +// without strict null checks, none of these should be an error import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; var unused1 = _object_spread({ b: 1 diff --git a/crates/swc/tests/tsc-references/strictBindCallApply2.1.normal.js b/crates/swc/tests/tsc-references/strictBindCallApply2.1.normal.js index 63ef9f66b3bb..e3b819b69620 100644 --- a/crates/swc/tests/tsc-references/strictBindCallApply2.1.normal.js +++ b/crates/swc/tests/tsc-references/strictBindCallApply2.1.normal.js @@ -1,4 +1,5 @@ //// [strictBindCallApply2.ts] +// Repro from #32964 function fn() {} var fb = fn.bind({ blub: "blub" diff --git a/crates/swc/tests/tsc-references/stringIndexerConstrainsPropertyDeclarations.1.normal.js b/crates/swc/tests/tsc-references/stringIndexerConstrainsPropertyDeclarations.1.normal.js index cc903d8522d6..53b93b72dad7 100644 --- a/crates/swc/tests/tsc-references/stringIndexerConstrainsPropertyDeclarations.1.normal.js +++ b/crates/swc/tests/tsc-references/stringIndexerConstrainsPropertyDeclarations.1.normal.js @@ -1,4 +1,5 @@ //// [stringIndexerConstrainsPropertyDeclarations.ts] +// String indexer types constrain the types of named properties in their containing type import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; var C = /*#__PURE__*/ function() { diff --git a/crates/swc/tests/tsc-references/stringLiteralTypeIsSubtypeOfString.1.normal.js b/crates/swc/tests/tsc-references/stringLiteralTypeIsSubtypeOfString.1.normal.js index 3ff04b725e71..796cf4780197 100644 --- a/crates/swc/tests/tsc-references/stringLiteralTypeIsSubtypeOfString.1.normal.js +++ b/crates/swc/tests/tsc-references/stringLiteralTypeIsSubtypeOfString.1.normal.js @@ -1,4 +1,6 @@ //// [stringLiteralTypeIsSubtypeOfString.ts] +// string literal types are subtypes of string, any +// ok import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f1(x) {} function f2(x) {} diff --git a/crates/swc/tests/tsc-references/stringLiteralTypesInImplementationSignatures2.1.normal.js b/crates/swc/tests/tsc-references/stringLiteralTypesInImplementationSignatures2.1.normal.js index 65f1cb8d5ce8..0d4fa712fab5 100644 --- a/crates/swc/tests/tsc-references/stringLiteralTypesInImplementationSignatures2.1.normal.js +++ b/crates/swc/tests/tsc-references/stringLiteralTypesInImplementationSignatures2.1.normal.js @@ -1,4 +1,5 @@ //// [stringLiteralTypesInImplementationSignatures2.ts] +// String literal types are only valid in overload signatures import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _define_property } from "@swc/helpers/_/_define_property"; function foo(x) {} diff --git a/crates/swc/tests/tsc-references/stringMappingDeferralInConditionalTypes.1.normal.js b/crates/swc/tests/tsc-references/stringMappingDeferralInConditionalTypes.1.normal.js index a7519051f6a0..da42b466e628 100644 --- a/crates/swc/tests/tsc-references/stringMappingDeferralInConditionalTypes.1.normal.js +++ b/crates/swc/tests/tsc-references/stringMappingDeferralInConditionalTypes.1.normal.js @@ -1,4 +1,5 @@ //// [stringMappingDeferralInConditionalTypes.ts] +// https://github.com/microsoft/TypeScript/issues/55847 var x1 = 1; // ok var x2 = 1; // ok var x3 = 1; // ok diff --git a/crates/swc/tests/tsc-references/stringMappingOverPatternLiterals.1.normal.js b/crates/swc/tests/tsc-references/stringMappingOverPatternLiterals.1.normal.js index 2ecfc4ee629f..81c7dbca5e20 100644 --- a/crates/swc/tests/tsc-references/stringMappingOverPatternLiterals.1.normal.js +++ b/crates/swc/tests/tsc-references/stringMappingOverPatternLiterals.1.normal.js @@ -1,4 +1,5 @@ //// [stringMappingOverPatternLiterals.ts] +// non-template function f1(a, b, c, a_template, b_template, c_template) { // non-template versions should be assignable to templated versions (empty string matches string) a_template = a; diff --git a/crates/swc/tests/tsc-references/subtypesOfAny.1.normal.js b/crates/swc/tests/tsc-references/subtypesOfAny.1.normal.js index 29bc12944672..28ea7dc2b355 100644 --- a/crates/swc/tests/tsc-references/subtypesOfAny.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypesOfAny.1.normal.js @@ -1,4 +1,5 @@ //// [subtypesOfAny.ts] +// every type is a subtype of any, no errors expected import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var A = function A() { "use strict"; diff --git a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer.1.normal.js index f10f2dce91ea..f4445436320a 100644 --- a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithNumericIndexer.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer3.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer3.1.normal.js index e1da128b103f..8f11acfa855e 100644 --- a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer3.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer3.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithNumericIndexer3.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer4.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer4.1.normal.js index 07ceb8ddf9ba..a94809f7c11e 100644 --- a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer4.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer4.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithNumericIndexer4.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer5.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer5.1.normal.js index 2f7298124de5..ee07fbb2d4c0 100644 --- a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer5.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer5.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithNumericIndexer5.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var B = function B() { "use strict"; diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality.1.normal.js index b2fd845b77d5..c68dddf69941 100644 --- a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithObjectMembersOptionality.ts] +// Derived member is not optional but base member is, should be ok // object literal case var a; var b = { diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality2.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality2.1.normal.js index 3ca8ee0f5100..c2ca02ed66c7 100644 --- a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality2.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality2.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithObjectMembersOptionality2.ts] +// Derived member is optional but base member is not, should be an error // object literal case var a; var b; diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality3.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality3.1.normal.js index e05b6dda6f96..8bbd5eebd206 100644 --- a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality3.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality3.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithObjectMembersOptionality3.ts] +// Base property is optional and derived type has no property of that name // object literal case var a; var b; diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality4.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality4.1.normal.js index 48d930204fbe..f86b3b31db9e 100644 --- a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality4.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality4.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithObjectMembersOptionality4.ts] +// Base has required property, derived adds an optional property, no errors // object literal case var a; var b; diff --git a/crates/swc/tests/tsc-references/subtypingWithStringIndexer.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithStringIndexer.1.normal.js index 604f974d46a4..67d1e4f70a23 100644 --- a/crates/swc/tests/tsc-references/subtypingWithStringIndexer.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithStringIndexer.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithStringIndexer.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/subtypingWithStringIndexer3.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithStringIndexer3.1.normal.js index 8054677e9d6d..91f8606071ec 100644 --- a/crates/swc/tests/tsc-references/subtypingWithStringIndexer3.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithStringIndexer3.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithStringIndexer3.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/subtypingWithStringIndexer4.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithStringIndexer4.1.normal.js index e2fd84aebcdf..218db35ba890 100644 --- a/crates/swc/tests/tsc-references/subtypingWithStringIndexer4.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithStringIndexer4.1.normal.js @@ -1,4 +1,5 @@ //// [subtypingWithStringIndexer4.ts] +// Derived type indexer must be subtype of base type indexer import { _ as _call_super } from "@swc/helpers/_/_call_super"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3.1.normal.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3.1.normal.js index 5d6deffa4a8c..ebb75280a2aa 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3.1.normal.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3.1.normal.js @@ -1,4 +1,5 @@ //// [taggedTemplateStringsWithOverloadResolution3.ts] +// Ambiguous call picks the first overload in declaration order import { _ as _tagged_template_literal } from "@swc/helpers/_/_tagged_template_literal"; function _templateObject() { var data = _tagged_template_literal([ diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3_ES6.1.normal.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3_ES6.1.normal.js index 56896dd4bd35..43a2687d3e0d 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3_ES6.1.normal.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3_ES6.1.normal.js @@ -1,4 +1,5 @@ //// [taggedTemplateStringsWithOverloadResolution3_ES6.ts] +// Ambiguous call picks the first overload in declaration order function fn1() { return null; } diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes3.1.normal.js b/crates/swc/tests/tsc-references/templateLiteralTypes3.1.normal.js index ff53645e35b1..2363f10d72aa 100644 --- a/crates/swc/tests/tsc-references/templateLiteralTypes3.1.normal.js +++ b/crates/swc/tests/tsc-references/templateLiteralTypes3.1.normal.js @@ -1,4 +1,5 @@ //// [templateLiteralTypes3.ts] +// Inference from template literal type to template literal type function f1(s, n, b, t) { var x1 = foo1('hello'); // Error var x2 = foo1('*hello*'); diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes4.1.normal.js b/crates/swc/tests/tsc-references/templateLiteralTypes4.1.normal.js index b6d3a9199dcd..b8417bbcb556 100644 --- a/crates/swc/tests/tsc-references/templateLiteralTypes4.1.normal.js +++ b/crates/swc/tests/tsc-references/templateLiteralTypes4.1.normal.js @@ -1,4 +1,5 @@ //// [templateLiteralTypes4.ts] +// infer from number p.getIndex(0); // ok, 0 is a valid index p.getIndex(1); // ok, 1 is a valid index p.getIndex(2); // error, 2 is not a valid index diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes5.1.normal.js b/crates/swc/tests/tsc-references/templateLiteralTypes5.1.normal.js index aae48561ecb1..b1ed7654a674 100644 --- a/crates/swc/tests/tsc-references/templateLiteralTypes5.1.normal.js +++ b/crates/swc/tests/tsc-references/templateLiteralTypes5.1.normal.js @@ -1,4 +1,5 @@ //// [templateLiteralTypes5.ts] +// https://github.com/microsoft/TypeScript/issues/55364 const f1 = f; const f2 = f; function f3(x) { diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes6.1.normal.js b/crates/swc/tests/tsc-references/templateLiteralTypes6.1.normal.js index 5829c50d8580..837be90a7c6b 100644 --- a/crates/swc/tests/tsc-references/templateLiteralTypes6.1.normal.js +++ b/crates/swc/tests/tsc-references/templateLiteralTypes6.1.normal.js @@ -1,4 +1,5 @@ //// [templateLiteralTypes6.ts] +// https://github.com/microsoft/TypeScript/issues/56659 function f2(scope, event) { f1(`${scope}:${event}`); } diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes7.1.normal.js b/crates/swc/tests/tsc-references/templateLiteralTypes7.1.normal.js index d496ab04d56e..23213ef967db 100644 --- a/crates/swc/tests/tsc-references/templateLiteralTypes7.1.normal.js +++ b/crates/swc/tests/tsc-references/templateLiteralTypes7.1.normal.js @@ -1,4 +1,5 @@ //// [templateLiteralTypes7.ts] +// https://github.com/microsoft/TypeScript/issues/57807 const g1 = g; // ok const g2 = g; // error const g3 = g; // ok diff --git a/crates/swc/tests/tsc-references/throwStatements.1.normal.js b/crates/swc/tests/tsc-references/throwStatements.1.normal.js index e3d60c2d45f8..cd3917283192 100644 --- a/crates/swc/tests/tsc-references/throwStatements.1.normal.js +++ b/crates/swc/tests/tsc-references/throwStatements.1.normal.js @@ -1,4 +1,5 @@ //// [throwStatements.ts] +// all legal import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _type_of } from "@swc/helpers/_/_type_of"; var C = function C() { diff --git a/crates/swc/tests/tsc-references/tsxElementResolution17.1.normal.js b/crates/swc/tests/tsc-references/tsxElementResolution17.1.normal.js index c2dbc6a19de3..fc9aad8cb821 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution17.1.normal.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution17.1.normal.js @@ -11,6 +11,8 @@ define([ "use strict"; }); //// [consumer.tsx] +/// +// Should keep s1 and elide s2 define([ "require", "exports", diff --git a/crates/swc/tests/tsc-references/tsxElementResolution19.1.normal.js b/crates/swc/tests/tsc-references/tsxElementResolution19.1.normal.js index 1a191bcda468..c290afc781c8 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution19.1.normal.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution19.1.normal.js @@ -32,6 +32,7 @@ define([ }; }); //// [file2.tsx] +// Should not elide React import define([ "require", "exports", diff --git a/crates/swc/tests/tsc-references/tsxPreserveEmit1.1.normal.js b/crates/swc/tests/tsc-references/tsxPreserveEmit1.1.normal.js index 7a553993431c..21df9d3e7f41 100644 --- a/crates/swc/tests/tsc-references/tsxPreserveEmit1.1.normal.js +++ b/crates/swc/tests/tsc-references/tsxPreserveEmit1.1.normal.js @@ -11,6 +11,7 @@ define([ "use strict"; }); //// [test.tsx] +// Should emit 'react-router' in the AMD dependency list define([ "require", "exports", diff --git a/crates/swc/tests/tsc-references/tsxPreserveEmit3.1.normal.js b/crates/swc/tests/tsc-references/tsxPreserveEmit3.1.normal.js index 100f96afa8a9..e154042f8208 100644 --- a/crates/swc/tests/tsc-references/tsxPreserveEmit3.1.normal.js +++ b/crates/swc/tests/tsc-references/tsxPreserveEmit3.1.normal.js @@ -28,6 +28,7 @@ define([ var React; }); //// [react-consumer.tsx] +// This import should be elided define([ "require", "exports", diff --git a/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule.1.normal.js b/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule.1.normal.js index 20ab131a80bc..50d6e6b6fce9 100644 --- a/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule.1.normal.js +++ b/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule.1.normal.js @@ -1,4 +1,5 @@ //// [twoInterfacesDifferentRootModule.ts] +// two interfaces with different root modules should not merge (function(M2) { var a; var r1 = a.foo; // error diff --git a/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads.1.normal.js b/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads.1.normal.js index 68bbf433bb56..c21eee905ed6 100644 --- a/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads.1.normal.js +++ b/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads.1.normal.js @@ -1,4 +1,5 @@ //// [twoMergedInterfacesWithDifferingOverloads.ts] +// interfaces that merge must not have members that conflict var b; var r = b.foo(true); // returns Date var c; diff --git a/crates/swc/tests/tsc-references/typeAliases.1.normal.js b/crates/swc/tests/tsc-references/typeAliases.1.normal.js index 52e16bbd0444..6d39109add92 100644 --- a/crates/swc/tests/tsc-references/typeAliases.1.normal.js +++ b/crates/swc/tests/tsc-references/typeAliases.1.normal.js @@ -1,4 +1,5 @@ //// [typeAliases.ts] +// Writing a reference to a type alias has exactly the same effect as writing the aliased type itself. import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var x1; var x1; diff --git a/crates/swc/tests/tsc-references/typeArgumentInferenceConstructSignatures.1.normal.js b/crates/swc/tests/tsc-references/typeArgumentInferenceConstructSignatures.1.normal.js index 6a6d5764c0d5..efbeba1e8585 100644 --- a/crates/swc/tests/tsc-references/typeArgumentInferenceConstructSignatures.1.normal.js +++ b/crates/swc/tests/tsc-references/typeArgumentInferenceConstructSignatures.1.normal.js @@ -1,4 +1,5 @@ //// [typeArgumentInferenceConstructSignatures.ts] +// Generic call with no parameters var noParams; new noParams(); new noParams(); diff --git a/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOfOnInterface.1.normal.js b/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOfOnInterface.1.normal.js index 186ec678e4a4..544262bba4f4 100644 --- a/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOfOnInterface.1.normal.js +++ b/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOfOnInterface.1.normal.js @@ -1,4 +1,9 @@ //// [typeGuardOfFormInstanceOfOnInterface.ts] +// A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function' +// and C has a property named 'prototype' +// - when true, narrows the type of x to the type of the 'prototype' property in C provided +// it is a subtype of the type of x, or +// - when false, has no effect on the type of x. import { _ as _instanceof } from "@swc/helpers/_/_instanceof"; var str; var num; diff --git a/crates/swc/tests/tsc-references/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.1.normal.js b/crates/swc/tests/tsc-references/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.1.normal.js index 2930b7484c2b..5a71e0a9e519 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.1.normal.js +++ b/crates/swc/tests/tsc-references/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.1.normal.js @@ -1,4 +1,5 @@ //// [typeOfThisInstanceMemberNarrowedWithLoopAntecedent.ts] +// #31995 import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var SomeClass = /*#__PURE__*/ function() { "use strict"; diff --git a/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraintTransitively.1.normal.js b/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraintTransitively.1.normal.js index 0d064ffcee7c..28a6ec569570 100644 --- a/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraintTransitively.1.normal.js +++ b/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraintTransitively.1.normal.js @@ -1,4 +1,6 @@ //// [typeParameterAsTypeParameterConstraintTransitively.ts] +// using a type parameter as a constraint for a type parameter is valid +// no errors expected var a; var b; var c; diff --git a/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraintTransitively2.1.normal.js b/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraintTransitively2.1.normal.js index 6ee9d63bdd79..52c5ffa07ade 100644 --- a/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraintTransitively2.1.normal.js +++ b/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraintTransitively2.1.normal.js @@ -1,4 +1,6 @@ //// [typeParameterAsTypeParameterConstraintTransitively2.ts] +// using a type parameter as a constraint for a type parameter is invalid +// these should be errors at the type parameter constraint declarations, and have no downstream errors var a; var b; var c; diff --git a/crates/swc/tests/tsc-references/typeParameterConstModifiersWithIntersection.1.normal.js b/crates/swc/tests/tsc-references/typeParameterConstModifiersWithIntersection.1.normal.js index 6f0c2db6c0a3..00b91fc4ce9d 100644 --- a/crates/swc/tests/tsc-references/typeParameterConstModifiersWithIntersection.1.normal.js +++ b/crates/swc/tests/tsc-references/typeParameterConstModifiersWithIntersection.1.normal.js @@ -1,4 +1,5 @@ //// [typeParameterConstModifiersWithIntersection.ts] +// https://github.com/microsoft/TypeScript/issues/55778 var result = test({ produceThing: {}, useIt: { diff --git a/crates/swc/tests/tsc-references/typeParametersAreIdenticalToThemselves.1.normal.js b/crates/swc/tests/tsc-references/typeParametersAreIdenticalToThemselves.1.normal.js index e775a3e328d4..cdae603e40b9 100644 --- a/crates/swc/tests/tsc-references/typeParametersAreIdenticalToThemselves.1.normal.js +++ b/crates/swc/tests/tsc-references/typeParametersAreIdenticalToThemselves.1.normal.js @@ -1,4 +1,5 @@ //// [typeParametersAreIdenticalToThemselves.ts] +// type parameters from the same declaration are identical to themself import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function foo1(x) {} function foo2(x) {} diff --git a/crates/swc/tests/tsc-references/typesWithOptionalProperty.1.normal.js b/crates/swc/tests/tsc-references/typesWithOptionalProperty.1.normal.js index 30ef58bca492..83a9a8ffa048 100644 --- a/crates/swc/tests/tsc-references/typesWithOptionalProperty.1.normal.js +++ b/crates/swc/tests/tsc-references/typesWithOptionalProperty.1.normal.js @@ -1,4 +1,5 @@ //// [typesWithOptionalProperty.ts] +// basic uses of optional properties without errors var a; var b = { foo: '' diff --git a/crates/swc/tests/tsc-references/unionAndIntersectionInference1.1.normal.js b/crates/swc/tests/tsc-references/unionAndIntersectionInference1.1.normal.js index ac1ff1effb20..f687a295cdfc 100644 --- a/crates/swc/tests/tsc-references/unionAndIntersectionInference1.1.normal.js +++ b/crates/swc/tests/tsc-references/unionAndIntersectionInference1.1.normal.js @@ -1,4 +1,5 @@ //// [unionAndIntersectionInference1.ts] +// Repro from #2264 var y = undefined; function destructure(something, haveValue, haveY) { return something === y ? haveY(y) : haveValue(something); diff --git a/crates/swc/tests/tsc-references/unionAndIntersectionInference3.1.normal.js b/crates/swc/tests/tsc-references/unionAndIntersectionInference3.1.normal.js index 79363807ed26..35923a2ec038 100644 --- a/crates/swc/tests/tsc-references/unionAndIntersectionInference3.1.normal.js +++ b/crates/swc/tests/tsc-references/unionAndIntersectionInference3.1.normal.js @@ -1,4 +1,5 @@ //// [unionAndIntersectionInference3.ts] +// Repro from #30720 concatMaybe([ 1, 2, diff --git a/crates/swc/tests/tsc-references/unionTypeCallSignatures5.1.normal.js b/crates/swc/tests/tsc-references/unionTypeCallSignatures5.1.normal.js index c2220c057fc4..e9265bf08f54 100644 --- a/crates/swc/tests/tsc-references/unionTypeCallSignatures5.1.normal.js +++ b/crates/swc/tests/tsc-references/unionTypeCallSignatures5.1.normal.js @@ -1,2 +1,3 @@ //// [unionTypeCallSignatures5.ts] +// #31485 fn(0); diff --git a/crates/swc/tests/tsc-references/unionTypeCallSignatures7.1.normal.js b/crates/swc/tests/tsc-references/unionTypeCallSignatures7.1.normal.js index 1d6a0e75a592..bf9eadd768f1 100644 --- a/crates/swc/tests/tsc-references/unionTypeCallSignatures7.1.normal.js +++ b/crates/swc/tests/tsc-references/unionTypeCallSignatures7.1.normal.js @@ -1,2 +1,3 @@ //// [unionTypeCallSignatures7.ts] +// https://github.com/microsoft/TypeScript/issues/55203 var result = f(123); diff --git a/crates/swc/tests/tsc-references/unknownType1.1.normal.js b/crates/swc/tests/tsc-references/unknownType1.1.normal.js index a3520dcf878a..8adac3798a62 100644 --- a/crates/swc/tests/tsc-references/unknownType1.1.normal.js +++ b/crates/swc/tests/tsc-references/unknownType1.1.normal.js @@ -1,4 +1,5 @@ //// [unknownType1.ts] +// In an intersection everything absorbs unknown import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _extends } from "@swc/helpers/_/_extends"; import { _ as _instanceof } from "@swc/helpers/_/_instanceof"; diff --git a/crates/swc/tests/tsc-references/variadicTuples1.1.normal.js b/crates/swc/tests/tsc-references/variadicTuples1.1.normal.js index 409f098250af..6f31817c4243 100644 --- a/crates/swc/tests/tsc-references/variadicTuples1.1.normal.js +++ b/crates/swc/tests/tsc-references/variadicTuples1.1.normal.js @@ -1,4 +1,5 @@ //// [variadicTuples1.ts] +// Variadics in tuple types import { _ as _to_array } from "@swc/helpers/_/_to_array"; import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array"; // Variadics in array literals diff --git a/crates/swc/tests/tsc-references/variance.1.normal.js b/crates/swc/tests/tsc-references/variance.1.normal.js index 4b3c1f64f774..fdccabf1f2b0 100644 --- a/crates/swc/tests/tsc-references/variance.1.normal.js +++ b/crates/swc/tests/tsc-references/variance.1.normal.js @@ -1,4 +1,6 @@ //// [variance.ts] +// Test cases for parameter variances affected by conditional types. +// Repro from #30047 import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var foo = { prop: true diff --git a/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.1.normal.js b/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.1.normal.js index b95836cc1c38..851187f56bbb 100644 --- a/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.1.normal.js +++ b/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.1.normal.js @@ -28,4 +28,5 @@ module.exports = I; const I = {}; module.exports = I; //// [/z.ts] +// test harness is weird if the last file includs a require >:( "use strict"; diff --git a/crates/swc_ecma_codegen/src/lib.rs b/crates/swc_ecma_codegen/src/lib.rs index 25ad0e760bd1..c60bf4e9dc31 100644 --- a/crates/swc_ecma_codegen/src/lib.rs +++ b/crates/swc_ecma_codegen/src/lib.rs @@ -1431,13 +1431,13 @@ impl MacroNode for Program { impl MacroNode for Module { #[tracing::instrument(level = "debug", skip_all)] fn emit(&mut self, emitter: &mut Macro) -> Result { - // Don't emit leading comments at Module level when the module has a body. - // This ensures that comments appear after any injected imports (e.g., helper - // imports) rather than before them. The first body item with a real - // span will emit the comments. - if self.body.is_empty() { - // For empty modules, emit leading comments to ensure they're not lost + let should_skip_leading_comments = self.body.iter().any(|s| s.span().lo == self.span.lo); + + if !should_skip_leading_comments { emitter.emit_leading_comments_of_span(self.span(), false)?; + } + + if self.body.is_empty() { srcmap!(emitter, self, true); } @@ -1463,13 +1463,13 @@ impl MacroNode for Module { impl MacroNode for Script { #[tracing::instrument(level = "debug", skip_all)] fn emit(&mut self, emitter: &mut Macro) -> Result { - // Don't emit leading comments at Script level when the script has a body. - // This ensures that comments appear after any injected imports (e.g., helper - // imports) rather than before them. The first body item with a real - // span will emit the comments. - if self.body.is_empty() { - // For empty scripts, emit leading comments to ensure they're not lost + let should_skip_leading_comments = self.body.iter().any(|s| s.span().lo == self.span.lo); + + if !should_skip_leading_comments { emitter.emit_leading_comments_of_span(self.span(), false)?; + } + + if self.body.is_empty() { srcmap!(emitter, self, true); } diff --git a/crates/swc_ecma_minifier/tests/benches-full/lodash.js b/crates/swc_ecma_minifier/tests/benches-full/lodash.js index a7fe496e3b5d..8adbfc500bd5 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/lodash.js +++ b/crates/swc_ecma_minifier/tests/benches-full/lodash.js @@ -1,4 +1,11 @@ -(function() { +/** + * @license + * Lodash + * Copyright OpenJS Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ (function() { /** Error message constants. */ var undefined, FUNC_ERROR_TEXT = 'Expected a function', HASH_UNDEFINED = '__lodash_hash_undefined__', PLACEHOLDER = '__lodash_placeholder__', INFINITY = 1 / 0, NAN = 0 / 0, wrapFlags = [ [ 'ary', diff --git a/crates/swc_ecma_minifier/tests/benches-full/moment.js b/crates/swc_ecma_minifier/tests/benches-full/moment.js index 77e38dbdc3c4..b7ee1362ffcd 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/moment.js +++ b/crates/swc_ecma_minifier/tests/benches-full/moment.js @@ -1,3 +1,8 @@ +//! moment.js +//! version : 2.29.1 +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors +//! license : MIT +//! momentjs.com !function(global, factory) { 'object' == typeof exports && 'undefined' != typeof module ? module.exports = factory() : 'function' == typeof define && define.amd ? define(factory) : global.moment = factory(); }(this, function() { diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/10054/for/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/10054/for/output.js index 03add9e136f1..f56109e68e95 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/10054/for/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/10054/for/output.js @@ -1,3 +1,4 @@ +// Input: window.a = [ function() { for(var l = 0; i < 10; l++); diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/10054/if/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/10054/if/output.js index 97d6b73ba25c..2be6daaec961 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/10054/if/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/10054/if/output.js @@ -1,3 +1,4 @@ +// Input: window.a = [ function() { if (void 0 !== navigator.userAgentData) throw Error(); diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/10539/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/10539/output.js index 9668116d4114..d63e501f0a34 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/10539/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/10539/output.js @@ -1,3 +1,4 @@ +// class def completely disappears // class def disappears, leaving only `new DoesntWorkClass()` as output (class DoesntWorkClass { static prop = new DoesntWorkClass(); diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/3256/2/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/3256/2/output.js index cfe08c349d6e..432be310b2b8 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/3256/2/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/3256/2/output.js @@ -1,3 +1,4 @@ +// real life example taken from https://github.com/nodeca/pako/blob/master/lib/zlib/adler32.js#L26 export default ((adler, buf, len, pos)=>{ let s1 = 0xffff & adler, s2 = adler >>> 16 & 0xffff, n = 0; for(; 0 !== len;){ diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js index 281a38f765fe..975819e75050 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js @@ -1,4 +1,4 @@ -var fn, cache, cursor, hyphenateRegex = /[A-Z]|^ms/g, animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g, unitless_browser_esm = { +/* harmony default export */ var fn, cache, cursor, hyphenateRegex = /[A-Z]|^ms/g, animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g, unitless_browser_esm = { animationIterationCount: 1, borderImageOutset: 1, borderImageSlice: 1, diff --git a/crates/swc_ecma_minifier/tests/fixture/member_expr/string/output.js b/crates/swc_ecma_minifier/tests/fixture/member_expr/string/output.js index 739cb408a995..282868dfc938 100644 --- a/crates/swc_ecma_minifier/tests/fixture/member_expr/string/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/member_expr/string/output.js @@ -1,2 +1,3 @@ +// Invalid // Object symbols ''.constructor, ''.__proto__, ''.__defineGetter__, ''.__defineSetter__, ''.__lookupGetter__, ''.__lookupSetter__, ''.hasOwnProperty, ''.isPrototypeOf, ''.propertyIsEnumerable, ''.toLocaleString, ''.toString, ''.valueOf, ''.anchor, ''.at, ''.big, ''.blink, ''.bold, ''.charAt, ''.charCodeAt, ''.codePointAt, ''.concat, ''.endsWith, ''.fixed, ''.fontcolor, ''.fontsize, ''.includes, ''.indexOf, ''.isWellFormed, ''.italics, ''.lastIndexOf, ''.link, ''.localeCompare, ''.match, ''.matchAll, ''.normalize, ''.padEnd, ''.padStart, ''.repeat, ''.replace, ''.replaceAll, ''.search, ''.slice, ''.small, ''.split, ''.startsWith, ''.strike, ''.sub, ''.substr, ''.substring, ''.sup, ''.toLocaleLowerCase, ''.toLocaleUpperCase, ''.toLowerCase, ''.toUpperCase, ''.toWellFormed, ''.trim, ''.trimEnd, ''.trimStart; diff --git a/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js b/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js index 263fd157bf4e..1b5ab8cce716 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js +++ b/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js @@ -1,4 +1,17 @@ -void 0 !== YUI && (YUI._YUI = YUI); +/* +YUI 3.12.0 (build 8655935) +Copyright 2013 Yahoo! Inc. All rights reserved. +Licensed under the BSD License. +http://yuilibrary.com/license/ +*/ /** +The YUI module contains the components required for building the YUI seed file. +This includes the script loading mechanism, a simple queue, and the core +utilities for the library. + +@module yui +@main yui +@submodule yui-base +**/ /*jshint eqeqeq: false*/ void 0 !== YUI && (YUI._YUI = YUI); /** The YUI global namespace object. This is the constructor for all YUI instances. diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.amd.ts b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.amd.ts index 36f7565073d3..79e854a5762c 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.amd.ts +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.amd.ts @@ -1,8 +1,8 @@ +/// define("NamedModule", [ "require" ], function(require) { "use strict"; - /// class Foo { x; constructor(){ diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.umd.ts b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.umd.ts index 29792c2f1708..4298ce2ab7b5 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.umd.ts +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.umd.ts @@ -1,10 +1,10 @@ +/// (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(); else if (typeof define === "function" && define.amd) define([], factory); else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(); })(this, function() { "use strict"; - /// class Foo { x; constructor(){ diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.amd.ts b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.amd.ts index 96aafcac4912..71a2d747bb6d 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.amd.ts +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.amd.ts @@ -1,9 +1,9 @@ +/// +/// define("SecondModuleName", [ "require" ], function(require) { "use strict"; - /// - /// class Foo { x; constructor(){ diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.umd.ts b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.umd.ts index ba1d81582529..12b46996a430 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.umd.ts +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.umd.ts @@ -1,11 +1,11 @@ +/// +/// (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(); else if (typeof define === "function" && define.amd) define([], factory); else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(); })(this, function() { "use strict"; - /// - /// class Foo { x; constructor(){ diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.amd.ts b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.amd.ts index 2aa6a35a7113..6540aa88dbd9 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.amd.ts +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.amd.ts @@ -1,8 +1,8 @@ +/// define("NamedModule", [ "require" ], function(require) { "use strict"; - /// class Foo { x; constructor(){ diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.umd.ts b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.umd.ts index 8a5d17feff2f..432a7737c98c 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.umd.ts +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.umd.ts @@ -1,10 +1,10 @@ +/// (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(); else if (typeof define === "function" && define.amd) define([], factory); else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(); })(this, function() { "use strict"; - /// class Foo { x; constructor(){ diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.amd.ts b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.amd.ts index f8bdf3485022..0b9663da8bec 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.amd.ts +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.amd.ts @@ -1,8 +1,8 @@ -define([ +/*/ */ define([ "require" ], function(require) { "use strict"; - /*/ */ class Foo { + class Foo { x; constructor(){ this.x = 5; diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.umd.ts b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.umd.ts index 8d8842a892d0..df69b0a6f956 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.umd.ts +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.umd.ts @@ -1,10 +1,10 @@ -(function(global, factory) { +/*/ */ (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(); else if (typeof define === "function" && define.amd) define([], factory); else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(); })(this, function() { "use strict"; - /*/ */ class Foo { + class Foo { x; constructor(){ this.x = 5; diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.amd.js index 989af835f5d0..975247161ce4 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.amd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.amd.js @@ -1,3 +1,6 @@ +// The fact that this exports both a normal default, and all of the names via +// re-export is an edge case that is important not to miss. See +// https://github.com/babel/babel/issues/8306 as an example. define([ "require", "exports", diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.cjs index 2b9784149772..a182aabfe5f4 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.cjs +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.cjs @@ -1,3 +1,6 @@ +// The fact that this exports both a normal default, and all of the names via +// re-export is an edge case that is important not to miss. See +// https://github.com/babel/babel/issues/8306 as an example. "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.umd.js index d9c218744eee..f6e8769e62fe 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.umd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/interop-node/export-all/output.umd.js @@ -1,3 +1,6 @@ +// The fact that this exports both a normal default, and all of the names via +// re-export is an edge case that is important not to miss. See +// https://github.com/babel/babel/issues/8306 as an example. (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("react")); else if (typeof define === "function" && define.amd) define([ diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.amd.js index a5c77652ebcd..c8786eb736e4 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.amd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.amd.js @@ -1,3 +1,6 @@ +// The fact that this exports both a normal default, and all of the names via +// re-export is an edge case that is important not to miss. See +// https://github.com/babel/babel/issues/8306 as an example. define([ "require", "exports", diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.cjs index 2414682bddf8..81ea12f189ce 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.cjs +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.cjs @@ -1,3 +1,6 @@ +// The fact that this exports both a normal default, and all of the names via +// re-export is an edge case that is important not to miss. See +// https://github.com/babel/babel/issues/8306 as an example. "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.umd.js index b7659e1dd2fa..b751da6870e1 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.umd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/interop/export-all/output.umd.js @@ -1,3 +1,6 @@ +// The fact that this exports both a normal default, and all of the names via +// re-export is an edge case that is important not to miss. See +// https://github.com/babel/babel/issues/8306 as an example. (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("react")); else if (typeof define === "function" && define.amd) define([ diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.amd.js index af4685b98189..27a7d82b1aa0 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.amd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.amd.js @@ -1,3 +1,4 @@ +// index.ts define([ "require", "exports", diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.cjs index 3be78a2fbca0..f756252eca8e 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.cjs +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.cjs @@ -1,3 +1,4 @@ +// index.ts "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.umd.js index 830f4299863d..25a982b752db 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.umd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-3732/output.umd.js @@ -1,3 +1,4 @@ +// index.ts (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("./get")); else if (typeof define === "function" && define.amd) define([ diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-7315/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-7315/output.amd.js index 224e7c877c72..b826cb60eee5 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-7315/output.amd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-7315/output.amd.js @@ -1,8 +1,8 @@ +// input.ts define([ "require", "exports" ], function(require, exports) { - // input.ts "use client"; "use strict"; Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-7315/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-7315/output.umd.js index 2513c7dca8a3..69d0b73bbe37 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-7315/output.umd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-7315/output.umd.js @@ -1,3 +1,4 @@ +// input.ts (function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") factory(exports); else if (typeof define === "function" && define.amd) define([ @@ -5,7 +6,6 @@ ], factory); else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}); })(this, function(exports) { - // input.ts "use client"; "use strict"; Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc_typescript/tests/fixture/symbol-getter-setter.snap b/crates/swc_typescript/tests/fixture/symbol-getter-setter.snap index 2ff0f67da208..4c50435beeec 100644 --- a/crates/swc_typescript/tests/fixture/symbol-getter-setter.snap +++ b/crates/swc_typescript/tests/fixture/symbol-getter-setter.snap @@ -1,5 +1,7 @@ ```==================== .D.TS ==================== +// @isolatedDeclarations: true +// @emitDeclarationOnly: true export declare const foo: { [Symbol.toStringTag]: string; }; diff --git a/crates/swc_typescript/tests/oxc_fixture/non-exported-binding-elements.snap b/crates/swc_typescript/tests/oxc_fixture/non-exported-binding-elements.snap index c27008d2b9f6..606b3594e4a5 100644 --- a/crates/swc_typescript/tests/oxc_fixture/non-exported-binding-elements.snap +++ b/crates/swc_typescript/tests/oxc_fixture/non-exported-binding-elements.snap @@ -1,5 +1,6 @@ ```==================== .D.TS ==================== +// Correct export declare function foo(): number; export { c, d, e }; export declare const { f, g } = { diff --git a/crates/swc_typescript/tests/oxc_fixture/strip-internal.snap b/crates/swc_typescript/tests/oxc_fixture/strip-internal.snap index e539063fd4c1..09a75f739548 100644 --- a/crates/swc_typescript/tests/oxc_fixture/strip-internal.snap +++ b/crates/swc_typescript/tests/oxc_fixture/strip-internal.snap @@ -1,6 +1,8 @@ ```==================== .D.TS ==================== -declare class StripInternalClassFields { +/* +@internal +*/ declare class StripInternalClassFields { } export { stripInternalFunction, StripInternalClass, StripInternalClassFields }; export interface StripInternalInterfaceSignatures {