Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/stupid-numbers-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_ecma_codegen: patch
swc_core: patch
---

fix(es/codegen): Emit comments of all nodes
Original file line number Diff line number Diff line change
@@ -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
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Simulate accessing a .js file in a third party package that shouldn't be edited
define([
"require",
"exports",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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([
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// index.ts
"use strict";
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions crates/swc/tests/fixture/jest/issue-7506/output/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/jest/issue-7506/output/util.map
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions crates/swc/tests/fixture/jest/issue-7506/output/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//// [accessorsOverrideProperty9.ts]
// #41347, based on microsoft/rushstack
// Mixin utilities
// Base class
class ApiItem {
get members() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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<T> to I2<I2<T>>, and they are self referencing anyway
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//// [assignmentCompatWithNumericIndexer2.ts]
// Derived type indexer must be subtype of base type indexer
var a;
var b;
a = b;
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//// [assignmentCompatWithStringIndexer2.ts]
// index signatures must be compatible in assignments
var a;
var b;
a = b; // ok
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 8 additions & 0 deletions crates/swc/tests/tsc-references/assignments.1.normal.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
//// [bivariantInferences.ts]
// Repro from #27337
var x = a.equalsShallow(b);
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//// [callChainInference.ts]
// Repro from #42404
if (value) {
value === null || value === void 0 ? void 0 : value.foo("a");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
//// [comparisonOperatorWithNumberOperand.ts]
// repro #52036
t1 >= 0; // error
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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];
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//// [constructSignatureAssignabilityInInheritance.ts]
// Checking basic subtype relations with construct signatures
(function(MemberWithConstructSignature) {
var b;
var r = new b.a(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//// [controlFlowAssignmentPatternOrder.ts]
// https://github.com/microsoft/TypeScript/pull/41094#issuecomment-716044363
{
let a = 0;
let b;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//// [covariantCallbacks.ts]
// Test that callback parameters are related covariantly
function f1(a, b) {
a = b;
b = a; // Error
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading