fix(es/parser): Adjust the context for cond expr while parsing JSX (#8261)

**Related issue:**

 - Closes #8243.
This commit is contained in:
Donny/강동윤 2023-11-10 22:07:53 +09:00 committed by GitHub
parent 6383ac443d
commit 0678c3c55f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1501 changed files with 1169 additions and 5168 deletions

View File

@ -0,0 +1,26 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true,
"dynamicImport": true
},
"transform": {
"react": {
"runtime": "automatic"
}
},
"baseUrl": "./",
"target": "es2019",
"keepClassNames": true,
"minify": {
"compress": false
}
},
"isModule": true,
"module": {
"type": "es6"
},
"minify": false
}

View File

@ -0,0 +1,7 @@
export const Foo = (props) => {
return originalMessage ? <Bar>
<Baz>
{(): unknown => null}
</Baz>
</Bar> : null;
};

View File

@ -0,0 +1,7 @@
export const Foo = (props) => {
return originalMessage ? <Bar>
<Baz>
{(): unknown => null}
</Baz>
</Bar> : null;
};

View File

@ -0,0 +1,7 @@
export const Foo = (props) => {
return originalMessage ? (<Bar>
<Baz>
{(): unknown => null}
</Baz>
</Bar>) : null;
};

View File

@ -0,0 +1,7 @@
export const Foo = (props) => {
return originalMessage ? <Bar>
<Baz>
{() => null}
</Baz>
</Bar> : null;
};

View File

@ -0,0 +1,8 @@
import { jsx as _jsx } from "react/jsx-runtime";
export const Foo = (props)=>{
return originalMessage ? _jsx(Bar, {
children: _jsx(Baz, {
children: ()=>null
})
}) : null;
};

View File

@ -0,0 +1,8 @@
import { jsx as _jsx } from "react/jsx-runtime";
export const Foo = (props)=>{
return originalMessage ? _jsx(Bar, {
children: _jsx(Baz, {
children: ()=>null
})
}) : null;
};

View File

@ -0,0 +1,8 @@
import { jsx as _jsx } from "react/jsx-runtime";
export const Foo = (props)=>{
return originalMessage ? _jsx(Bar, {
children: _jsx(Baz, {
children: ()=>null
})
}) : null;
};

View File

@ -0,0 +1,8 @@
import { jsx as _jsx } from "react/jsx-runtime";
export const Foo = (props)=>{
return originalMessage ? _jsx(Bar, {
children: _jsx(Baz, {
children: ()=>null
})
}) : null;
};

View File

@ -2,4 +2,3 @@
//// [class.d.ts]
//// [test.ts]
A.Point.Origin, new A.Point(0, 0);
// unexpected error here, bug 840000

View File

@ -7,4 +7,3 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
};
//// [test.ts]
A.Point.Origin, new A.Point(0, 0);
// unexpected error here, bug 840000

View File

@ -1,5 +1,4 @@
//// [ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts]
// all expected to be errors
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var clodule1 = function clodule1() {
_class_call_check(this, clodule1);

View File

@ -4,8 +4,7 @@ var A, Point, A1, Point1 = function() {
function Point(x, y) {
_class_call_check(this, Point), this.x = x, this.y = y;
}
return Point.Origin // unexpected error here bug 840246
= function() {
return Point.Origin = function() {
return {
x: 0,
y: 0
@ -14,13 +13,11 @@ var A, Point, A1, Point1 = function() {
}();
(Point1 || (Point1 = {})).Origin = function() {
return null;
} //expected duplicate identifier error
, A = A1 || (A1 = {}), Point = function() {
}, A = A1 || (A1 = {}), Point = function() {
function Point(x, y) {
_class_call_check(this, Point), this.x = x, this.y = y;
}
return Point.Origin // unexpected error here bug 840246
= function() {
return Point.Origin = function() {
return {
x: 0,
y: 0
@ -28,5 +25,4 @@ var A, Point, A1, Point1 = function() {
}, Point;
}(), A.Point = Point, (Point = A.Point || (A.Point = {})).Origin = function() {
return "";
} //expected duplicate identifier error
;
};

View File

@ -8,9 +8,7 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var X, X1, Y, Point;
(Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0);
//// [test.ts]
//var cl: { x: number; y: number; }
new X.Y.Point(1, 1), X.Y.Point.Origin;
// error not expected here same as bug 83996 ?
//// [simple.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var A, A1 = function A() {

View File

@ -9,9 +9,7 @@ var X, X1;
var X, X1, Y, Point;
(Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0);
//// [test.ts]
//var cl: { x: number; y: number; }
new X.Y.Point(1, 1), X.Y.Point.Origin;
// error not expected here same as bug 83996 ?
//// [simple.ts]
var A;
class A1 {

View File

@ -1,5 +1,4 @@
//// [ES5For-of37.ts]
// https://github.com/microsoft/TypeScript/issues/30083
for(var _i = 0, _iter = [
0,
1,
@ -9,7 +8,6 @@ for(var _i = 0, _iter = [
]; _i < _iter.length; _i++){
var i = _iter[_i];
try {
// Ensure catch binding for the following loop is reset per iteration:
for(var _i1 = 0, _iter1 = [
1,
2,

View File

@ -1,5 +1,4 @@
//// [ES5For-ofTypeCheck10.ts]
// In ES3/5, you cannot for...of over an arbitrary iterable.
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var StringIterator = function() {
function StringIterator() {

View File

@ -6,4 +6,4 @@ M1 = M || (M = {}), C = function() {
_class_call_check(this, C);
}
return C.prototype[_$Symbol.iterator] = function() {}, C;
}(), M1.C = C, /*#__PURE__*/ (new C)[_$Symbol.iterator], (new M.C)[Symbol.iterator];
}(), M1.C = C, (new C)[_$Symbol.iterator], (new M.C)[Symbol.iterator];

View File

@ -6,5 +6,4 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
_class_call_check(this, C);
}
return C.prototype[Symbol.iterator] = function() {}, C;
}()))[Symbol.iterator](0) // Should error
;
}()))[Symbol.iterator](0);

View File

@ -14,7 +14,6 @@ var A, A1;
};
//// [test.ts]
A.Point, A.Point(), A.Point.Origin;
// not expected to be an error.
//// [simple.ts]
var B;
!function(B) {

View File

@ -1,3 +1,2 @@
//// [InvalidNonInstantiatedModule.ts]
M; // Error, not instantiated can not be used as var
// Error only a namespace
M;

View File

@ -10,7 +10,6 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
//// [simple.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(A = A1 || (A1 = {})).Instance = new A();
// duplicate identifier
var A, A1 = function A() {
_class_call_check(this, A);
};

View File

@ -16,7 +16,6 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
_class_call_check(this, Plane), this.tl = tl, this.br = br;
};
//// [part3.ts]
// test the merging actually worked
var o = A.Origin, o = A.Utils.mirror(o);
new A.Utils.Plane(o, {
x: 1,

View File

@ -16,7 +16,6 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
_class_call_check(this, Plane), this.tl = tl, this.br = br;
};
//// [part3.ts]
// test the merging actually worked
var o = A.Origin, o = A.Utils.mirror(o);
new A.Utils.Plane(o, {
x: 1,

View File

@ -1,6 +1,5 @@
//// [accessorsAreNotContextuallyTyped.ts]
// accessors are not contextually typed
var c;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _create_class } from "@swc/helpers/_/_create_class";
c.x(""); // string
c.x("");

View File

@ -9,5 +9,5 @@ const obj = new class extends Base {
set x(value) {
console.log(`x was set to ${value}`);
}
}(); // nothing printed
console.log(obj.x); // number
}();
console.log(obj.x);

View File

@ -1,7 +1,4 @@
//// [accessorsOverrideProperty9.ts]
// #41347, based on microsoft/rushstack
// Mixin utilities
// Base class
class ApiItem {
get members() {
return [];
@ -17,9 +14,7 @@ function ApiItemContainerMixin(baseClass) {
}
};
}
// Subclass inheriting from mixin
export class ApiEnum extends ApiItemContainerMixin(ApiItem) {
// This worked prior to TypeScript 4.0:
get members() {
return [];
}

View File

@ -1,2 +1 @@
//// [additionOperatorWithConstrainedTypeParameter.ts]
// test for #17069

View File

@ -1,2 +1 @@
//// [additionOperatorWithNullValueAndInvalidOperator.ts]
// If one operand is the null or undefined value, it is treated as having the type of the other operand.

View File

@ -1,4 +1,3 @@
//// [additionOperatorWithNullValueAndValidOperator.ts]
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
var E, E1;
(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c";

View File

@ -1,2 +1 @@
//// [additionOperatorWithOnlyNullValueOrUndefinedValue.ts]
// bug 819721

View File

@ -1,4 +1,3 @@
//// [additionOperatorWithTypeParameter.ts]
// type parameter type is not a valid operand of addition operator
var E, E1;
(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b";

View File

@ -1,2 +1 @@
//// [additionOperatorWithUndefinedValueAndInvalidOperands.ts]
// If one operand is the null or undefined value, it is treated as having the type of the other operand.

View File

@ -1,4 +1,3 @@
//// [additionOperatorWithUndefinedValueAndValidOperator.ts]
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
var E, E1;
(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c";

View File

@ -1,2 +1 @@
//// [ambientAccessors.ts]
// ok to use accessors in ambient class in ES3

View File

@ -1,3 +1,2 @@
//// [ambientDeclarations.ts]
// Ambient variable without type annotation
E3.B, M1.x, M1.fn();

View File

@ -1,7 +1,5 @@
//// [ambientDeclarationsExternal.ts]
//// [decls.ts]
// Ambient external module with export assignment
// Ambient external import declaration referencing ambient external module using top level module name
//// [consumer.ts]
//!
//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead.

View File

@ -1,10 +1,8 @@
//// [declarations.d.ts]
//// [user.ts]
///<reference path="declarations.d.ts" />
import { foo, baz } from "foobarbaz";
foo(baz);
import { foos } from "foosball";
foo(foos);
// Works with relative file name
import fileText from "./file!text";
foo(fileText);

View File

@ -3,4 +3,3 @@
export { };
//// [testB.ts]
export { };
// Error

View File

@ -1,5 +1,4 @@
//// [types.ts]
//// [test.ts]
ohno.a // oh no
;
ohno.a;
export { };

View File

@ -1,2 +1 @@
//// [ambientEnumDeclaration1.ts]
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.

View File

@ -1,3 +1 @@
//// [ambientEnumDeclaration2.ts]
// In ambient enum declarations that specify no const modifier, enum member declarations
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).

View File

@ -1,6 +1,4 @@
//// [declarations1.d.ts]
//// [declarations2.d.ts]
//// [user.ts]
///<reference path="declarations1.d.ts" />
///<reference path="declarations1.d.ts" />
export { };

View File

@ -1,6 +1,4 @@
//// [declarations1.d.ts]
//// [declarations2.d.ts]
//// [user.ts]
///<reference path="declarations1.d.ts" />
///<reference path="declarations1.d.ts" />
export { };

View File

@ -6,5 +6,4 @@ export * from "jquery";
//// [reExportUser.ts]
import { x } from "./reExportX";
import * as $ from "./reExportAll";
// '$' is not callable, it is an object.
x($);

View File

@ -1,9 +1,8 @@
//// [Compilation.js]
// from webpack/lib/Compilation.js and filed at #26427
/** @param {{ [s: string]: number }} map */ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
export var C = function() {
function C() {
_class_call_check(this, C), /** @type {{ [assetName: string]: number}} */ this.assets = {};
_class_call_check(this, C), this.assets = {};
}
return C.prototype.m = function() {
this.assets;

View File

@ -1,6 +1,3 @@
//// [anyAsConstructor.ts]
// any is considered an untyped function call
// can be called except with type arguments which is an error
var x;
new x(), new x("hello"), new x(x), new x(x);
// no error

View File

@ -1,5 +1,3 @@
//// [anyAsFunctionCall.ts]
// any is considered an untyped function call
// can be called except with type arguments which is an error
var x;
x(), x("hello"), x(x);

View File

@ -1,6 +1,4 @@
//// [anyAsGenericFunctionCall.ts]
// any is considered an untyped function call
// can be called except with type arguments which is an error
var x;
import "@swc/helpers/_/_class_call_check";
x(), x("hello"), x(x), x(x);

View File

@ -1,5 +1,4 @@
//// [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";
function f() {}
foo2(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), (E = E1 || (E1 = {}))[E.A = 0] = "A", foo3(a), (f || (f = {})).bar = 1, foo3(a);
@ -7,4 +6,3 @@ var E, a, E1, CC = function CC() {
_class_call_check(this, CC);
};
(CC || (CC = {})).bar = 1, foo3(a), foo3(a), foo3(a);
// any

View File

@ -2,8 +2,3 @@
var E, E1;
import "@swc/helpers/_/_class_call_check";
(E1 = E || (E = {}))[E1.A = 0] = "A";
//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) {
// x = a;
// y = a;
// z = a;
//}

View File

@ -1,5 +1,4 @@
//// [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";
function f() {}
(E = E1 || (E1 = {}))[E.A = 0] = "A", (f || (f = {})).bar = 1;

View File

@ -1,6 +1,4 @@
//// [apparentTypeSubtyping.ts]
// subtype checks use the apparent type of the target type
// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S:
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";

View File

@ -1,6 +1,4 @@
//// [apparentTypeSupertype.ts]
// subtype checks use the apparent type of the target type
// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S:
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";

View File

@ -1,5 +1,4 @@
//// [argumentExpressionContextualTyping.ts]
// In a typed function call, argument expressions are contextually typed by their corresponding parameter types.
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
function foo(param) {
@ -45,4 +44,3 @@ foo({
e: 3
}
});
// Error because x has an array type namely (string|number)[]

View File

@ -1,4 +1,3 @@
//// [arithmeticOperatorWithEnum.ts]
// operands of an enum type are treated as having the primitive type Number.
var E, E1;
(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b";

View File

@ -1,4 +1,3 @@
//// [arithmeticOperatorWithEnumUnion.ts]
// operands of an enum type are treated as having the primitive type Number.
var E, F, E1, F1;
(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", (F1 = F || (F = {}))[F1.c = 0] = "c", F1[F1.d = 1] = "d";

View File

@ -1,5 +1,3 @@
//// [arithmeticOperatorWithInvalidOperands.ts]
// these operators require their operands to be of type Any, the Number primitive type, or
// an enum type
var E, E1;
(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c";

View File

@ -1,2 +1 @@
//// [arithmeticOperatorWithTypeParameter.ts]
// type parameter type is not valid for arithmetic operand

View File

@ -1,2 +1 @@
//// [arrayLiteral.ts]
// valid uses of array literals

View File

@ -1,7 +1,4 @@
//// [arrayLiteralExpressionContextualTyping.ts]
// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by
// the type of the property with the numeric name N in the contextual type, if any, or otherwise
// the numeric index type of the contextual type, if any.
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
var tup = [
1,
@ -26,4 +23,3 @@ var tup = [
2,
3
].concat(_to_consumable_array(tup));
// Error

View File

@ -1,5 +1,4 @@
//// [arrayLiteralInference.ts]
// Repro from #31204
var AppType, AppStyle;
var AppType1;
export { AppType1 as AppType };

View File

@ -1,2 +1 @@
//// [arrayLiteralWidened.ts]
// array literals are widened upon assignment according to their element type

View File

@ -1,3 +1 @@
//// [arrayLiteralWithMultipleBestCommonTypes.ts]
// when multiple best common types exist we will choose the first candidate
// (b: { x: number; z?: number }) => number[]

View File

@ -1,5 +1,4 @@
//// [arrayLiterals.ts]
// Empty array literal with no contextual type has type Undefined[]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
@ -7,7 +6,6 @@ var C = function C() {
_class_call_check(this, C);
};
new C(), new C();
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
var Base = function Base() {
_class_call_check(this, Base);
}, Derived1 = function(Base) {

View File

@ -1,11 +1,4 @@
//// [arrayLiterals2ES5.ts]
// ElementList: ( Modified )
// Elisionopt AssignmentExpression
// Elisionopt SpreadElement
// ElementList, Elisionopt AssignmentExpression
// ElementList, Elisionopt SpreadElement
// SpreadElement:
// ... AssignmentExpression
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
var a0 = [
,
@ -30,11 +23,8 @@ var _ref = [
1,
2,
!0
]; // tuple type [number, number, boolean]
];
_ref[0], _ref[1];
// The resulting type an array literal expression is determined as follows:
// - the resulting type is an array type with an element type that is the union of the types of the
// non - spread element expressions and the numeric index signature types of the spread element expressions
var temp = [
"s",
"t",

View File

@ -1,11 +1,4 @@
//// [arrayLiterals2ES6.ts]
// ElementList: ( Modified )
// Elisionopt AssignmentExpression
// Elisionopt SpreadElement
// ElementList, Elisionopt AssignmentExpression
// ElementList, Elisionopt SpreadElement
// SpreadElement:
// ... AssignmentExpression
var a0 = [
,
,
@ -26,9 +19,6 @@ var a0 = [
[
...a0
];
// The resulting type an array literal expression is determined as follows:
// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1),
// the resulting type is a tuple type constructed from the types of the element expressions.
var [c0, c1] = [
1,
2
@ -44,7 +34,7 @@ var [c0, c1] = [
1,
2,
3
]; // tuple type [number, number]
];
[
...temp
], [

View File

@ -1,15 +1,5 @@
//// [arrayLiterals3.ts]
// Each element expression in a non-empty array literal is processed as follows:
// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19)
// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal,
// the element expression is contextually typed by the type of that property.
// The resulting type an array literal expression is determined as follows:
// - If the array literal contains no spread elements and is contextually typed by a tuple-like type,
// the resulting type is a tuple type constructed from the types of the element expressions.
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
// The resulting type an array literal expression is determined as follows:
// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1),
// the resulting type is a tuple type constructed from the types of the element expressions.
var _ref = [
1,
2,
@ -37,4 +27,3 @@ _to_consumable_array([
"t",
"r"
]));
// Error cannot assign (number|string)[] to number[]

View File

@ -2,4 +2,3 @@
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
// List<number>[]

View File

@ -1,5 +1,4 @@
//// [arrayOfFunctionTypes3.ts]
// valid uses of arrays of function types
var a, a2, b2, c2;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
[
@ -14,4 +13,3 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
b2,
c2
][0])("");
// any not string

View File

@ -10,4 +10,3 @@ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
4
]);
//// [tslib.d.ts]
// this is a pre-TS4.4 versions of emit helper, which always forced array packing

View File

@ -52,5 +52,4 @@ f1.apply(void 0, [
]), (_action = action).run.apply(_action, [
100,
"foo"
] // error
);
]);

View File

@ -1,9 +1,7 @@
//// [arrayTypeOfFunctionTypes.ts]
// valid uses of arrays of function types
var x2, r = (void 0)[1];
r(), new r();
var r3 = x2[1];
r3(), new r3();
var r5 = x2[1];
r5(), new r5();
// error

View File

@ -1,5 +1,4 @@
//// [arrayTypeOfFunctionTypes2.ts]
// valid uses of arrays of function types
var x, x2, r = x[1];
new r(), r();
var r3 = x[1];

View File

@ -1,2 +1 @@
//// [arrayTypeOfTypeOf.ts]
// array type cannot use typeof.

View File

@ -1,5 +1,4 @@
//// [arrowFunctionExpressions.ts]
// ArrowFormalParameters => AssignmentExpression is equivalent to ArrowFormalParameters => { return AssignmentExpression; }
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import "@swc/helpers/_/_sliced_to_array";
import "@swc/helpers/_/_to_array";

View File

@ -1,5 +1,2 @@
//// [asOpEmitParens.ts]
// Must emit as (x + 1) * 3
x, // Should still emit as x.y
x.y, // Emit as new (x())
new (x());
x, x.y, new (x());

View File

@ -12,4 +12,3 @@ function _templateObject() {
as(_templateObject()), as(function Foo() {
_class_call_check(this, Foo);
});
// should emit

View File

@ -1,2 +1,2 @@
//// [asOperatorAmbiguity.ts]
(void 0)[0].m; // z should be string
(void 0)[0].m;

View File

@ -1,2 +1 @@
//// [asOperatorContextualType.ts]
// should error

View File

@ -1,2 +1 @@
//// [asiPreventsParsingAsAmbientExternalModule01.ts]
// this is a block body

View File

@ -1,2 +1 @@
//// [asiPreventsParsingAsNamespace01.ts]
// this is a block body

View File

@ -1,2 +1 @@
//// [asiPreventsParsingAsNamespace02.ts]
// this is a block body

View File

@ -1,13 +1,6 @@
//// [assertionTypePredicates2.js]
/**
* @typedef {{ x: number }} A
*/ /**
* @typedef { A & { y: number } } B
*/ /**
* @param {A} a
* @returns { asserts a is B }
*/ var foo = function(a) {
if (0 !== /** @type { B } */ a.y) throw TypeError();
var foo = function(a) {
if (0 !== a.y) throw TypeError();
};
export var main = function() {
foo({

View File

@ -1,2 +1 @@
//// [assertionsAndNonReturningFunctions.js]
/** @typedef {(check: boolean) => asserts check} AssertFunc */ /** @type {AssertFunc} */

View File

@ -1,5 +1,4 @@
//// [assignAnyToEveryType.ts]
// all of these are valid
var E, M, E1;
import "@swc/helpers/_/_class_call_check";
(E1 = E || (E = {}))[E1.A = 0] = "A", (M || (M = {})).foo = 1;

View File

@ -1,5 +1,4 @@
//// [assignEveryTypeToAny.ts]
// all of these are valid
var E, E1;
import "@swc/helpers/_/_class_call_check";
(E1 = E || (E = {}))[E1.A = 0] = "A";

View File

@ -1,2 +1 @@
//// [assignFromBooleanInterface2.ts]
// expected error

View File

@ -1,2 +1 @@
//// [assignFromNumberInterface2.ts]
// expected error

View File

@ -1,2 +1 @@
//// [assignFromStringInterface2.ts]
// expected error

View File

@ -1,2 +1 @@
//// [assignmentCompatWithCallSignatures.ts]
// void returning call signatures can be assigned a non-void returning call signature that otherwise matches

View File

@ -1,2 +1 @@
//// [assignmentCompatWithCallSignatures2.ts]
// void returning call signatures can be assigned a non-void returning call signature that otherwise matches

View File

@ -1,6 +1,4 @@
//// [assignmentCompatWithCallSignatures3.ts]
// these are all permitted with the current rules, since we do not do contextual signature instantiation
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
// ok

View File

@ -1,5 +1,4 @@
//// [assignmentCompatWithCallSignatures4.ts]
// These are mostly permitted with the current loose rules. All ok unless otherwise noted.
var Errors, WithNonGenericSignaturesInBaseType, WithGenericSignaturesInBaseType;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";

View File

@ -1,6 +1,4 @@
//// [assignmentCompatWithCallSignatures5.ts]
// checking assignment compat for function types. No errors in this file
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
// ok

View File

@ -1,5 +1,4 @@
//// [assignmentCompatWithCallSignatures6.ts]
// checking assignment compatibility relations for function types. All valid
var x, b, b2, b3, b4, b5, b11, b16;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";

View File

@ -1,5 +1,3 @@
//// [assignmentCompatWithCallSignaturesWithOptionalParameters.ts]
// call signatures in derived types must have the same or fewer optional parameters as the base type
var b;
b.a, b.a2, b.a3, b.a4, b.a5, b.a6, b.a, b.a2, b.a3, b.a4, b.a5, b.a6, b.a, b.a2, b.a3, b.a4, b.a5, b.a6, b.a, b.a2, b.a3, b.a4, b.a5, b.a6, b.a, b.a2, b.a3, b.a4, b.a5, b.a6;
// ok, same number of params

View File

@ -1,3 +1 @@
//// [assignmentCompatWithCallSignaturesWithRestParameters.ts]
// call signatures in derived types must have the same or fewer optional parameters as the target for assignment
// error, rest params have type mismatch

View File

@ -1,2 +1 @@
//// [assignmentCompatWithConstructSignatures.ts]
// void returning call signatures can be assigned a non-void returning call signature that otherwise matches

View File

@ -1,2 +1 @@
//// [assignmentCompatWithConstructSignatures2.ts]
// void returning call signatures can be assigned a non-void returning call signature that otherwise matches

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