mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Private named instance fields (#30829)
* Fix display of private names in language server Signed-off-by: Joseph Watts <jwatts43@bloomberg.net> Signed-off-by: Max Heiber <max.heiber@gmail.com> * Parse private names Signed-off-by: Max Heiber <max.heiber@gmail.com> * update parser error recovery tests to use ¬ not # The intent of the tests seemed to be to regiment the behavior of the parser when a weird symbol is encountered. The `#` is now taken by private identifiers, so `¬` seems like a good new choice for keeping the diff small, since it also fits in 16 bits (wide emojis would be treated as multiple characters, since the scanner uses ++). Signed-off-by: Max Heiber <max.heiber@gmail.com> * Private Name Support in the Checker (#5) - [x] treat private names as unique: - case 1: cannot say that a variable is of a class type unless the variable points to an instance of the class - see [test](https://github.com/mheiber/TypeScript/tree/checker/tests/cases/conformance/classes/members/privateNames/privateNamesUnique.ts) - case 2: private names in class hierarchies do not conflict - see [test](https://github.com/mheiber/TypeScript/tree/checker/tests/cases/conformance/classes/members/privateNames/privateNamesNoConflictWhenInheriting.ts) - [x] `#constructor` is reserved - see [test](https://github.com/mheiber/TypeScript/tree/checker/tests/cases/conformance/classes/members/privateNames/privateNameConstructorReserved.ts) - check in `bindWorker`, where every node is visited - [x] Accessibility modifiers can't be used with private names - see [test](https://github.com/mheiber/TypeScript/tree/checker/tests/cases/conformance/classes/members/privateNames/privateNamesNoAccessibilityModifiers.ts) - implemented in `checkAccessibilityModifiers`, using `ModifierFlags.AccessibilityModifier` - [x] `delete #foo` not allowed - [x] Private name accesses not allowed outside of the defining class - see test: https://github.com/mheiber/TypeScript/tree/checker/tests/cases/conformance/classes/members/privateNames/privateNameNotAccessibleOutsideDefiningClass.ts - see [test](https://github.com/mheiber/TypeScript/tree/checker/tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts) - implemented in `checkDeleteExpression` - [x] Do [the right thing](https://gist.github.com/mheiber/b6fc7adb426c2e1cdaceb5d7786fc630) for nested classes mv private name tests together more checker tests for private names update naming and cleanup for check private names for private name support in the checker: - make names more consistent - remove unnecessary checks - add utility function to public API - other small cleanup Move getPropertyNameForUniqueESSymbol to utility for consistency with other calculation of special property names (starting with __), move the calculation of property names for unique es symbols to `utilities.ts`. private name tests strict+es6 Update private name tests to use 'strict' type checking and to target es6 instead of default. Makes the js output easier to read and tests more surface area with other checker features. error message for private names in obj literals Disallow decorating private-named properties because the spec is still in flux. Signed-off-by: Max Heiber <max.heiber@gmail.com> * Add private instance field transformation, pr feedback Implements private instance fields on top of the class properties refactor. This commit also includes incorporation of PR feedback on the checker, parser, and transformer in order to make the rebase manageable. Co-Authored-By: Max Heiber <max.heiber@gmail.com> Co-Authored-By: Ron Buckton <ron.buckton@microsoft.com> Signed-off-by: Joey Watts <jwatts43@bloomberg.net> Signed-off-by: Max Heiber <max.heiber@gmail.com> Incorporate PR feedback Fix checker crash with new block scoped bindings Add classExpressionInLoop test Update baselines for private name errors Apply suggestions from code review Fix privateNameFieldCallExpression test Remove unnecessary comment Fix PropertyAccessEntityNameExpression type Remove PrivateName from PropertyNameLiteral Add createPrivateName Remove PrivateName type from textSourceNode Add Debug asserts for invalid syntax kinds Don't output private name syntax when undeclared Make PrivateName extend Node Update baselines for public API Fix completions in language server Fix fourslash test crash intern private name descriptions undo expensive node.name.parent assignment Back the way things were on `master`: only assign node.name.parent when we need to Add tests for private names and JSDoc Patch hoverOverPrivateName fourslash test Fix goToDefinition for private-named fields remove Debug.fail for private name outside class Remove Debug.fail in binder.ts::`getDeclarationName`. It turns out this code path *does* get hit (intentionally). For best error messages, return `undefined` and rely on the parser generating a good error message "Private names are not allowed outside class bodies" Add rbuckton test cases for private names These test cases specifically exercise where we needed to use name-mangling. They are cases where private names have the same description. - private names no conflict when inheriting - private names distinct even when the two classes have the same name check dup instance+static private identifiers class A { #foo; static #foo; } not allowed because static and private names share the same lexical scope https://tc39.es/proposal-class-fields/#prod-ClassBody refactor getPropertyForPrivateName, rel spans refactor getPropertyForPrivateName so it is easier to read (use findAncestor instead of loop). Fix bugs in getPropertyForPrivateName: - make it work with deeply-nested classes with and without shadowing - make it catch shadowing when the conflict is between static and instance private name descriptions (these can actually clash) And add related spans to diagnostics for getPropertyForPrivateName catch conflicts between static and instance private identifiers: - cannot have an instance and static private identifier with the same spelling, as there is only one namespace for private names rename 'PrivateName' to 'PrivateIdentifier' to match the change of wording in the spec prposal: https://tc39.es/proposal-class-fields/#sec-syntax The rename in the spec was to avoid confusion between the AST Node PrivateIdentifier and the internal spec type PrivateName. So one uses the [[Description]] of a PrivateIdentifier to look up the PrivateName for a given scope. This corresponds closely to our implementation in the binder and checker: - we mangle PrivateIdentifier.escapedText to get a `key` which we use to get the symbol for a property f getLiteralTypeFromProperty-check privateIdentifier rename and simplify privateNameAndAny test case make it clearer that all this test is showing is that we allow accessing arbitrary private identifiers on `any`. Note: we could have something more sound here by checking that there is a private-named field declaration in a class scope above the property access. Discussion: https://github.com/microsoft/TypeScript/pull/30829/files#r302760015 Fix typo in checker s/identifer/identifier remove accidental change patch fourslash test broken by isPrivateIdentifier just needed to add a check to see if the symbol .name is defined extract reportUnmatchedProperty per @nsandersn feedback propertiesRelatedTo was getting to long pull out the unmatchedProperty reporting into a seprate function fix typo in private names test Fix type soundness with private names Remove PrivateIdentifier from emit with Expr hint Fixup helpers and set function name for privates remove accidentally-committed baselines These baselines somehow ended up in this pr, though they have nothing to do with the changes Revert "getLiteralTypeFromProperty-check privateIdentifier" This reverts commit bd1155c300bc3517a0543580f4790268f86e473f. reason: the check for isIdentifier in getLiteralTypeFromProperty is superfluous because we do this check in getLiteralTypeFromPropertyName Update comment in private name uniqueness test 3 I think the comments were not accurate and that we export the error on `this.#x = child.#x` because: - private names are lexically scoped: the code in question is not in a lexical scope under the definition of Child's #x. - private names are private to their containing class: never inherited This expected behavior matches that of Chrome Canary and my understanding of the spec test private names use before def, circular ref test private names use before def, circular ref update diagnosticMessages s/delete/'delete' per @DanielRosenwasser and @sandersn guidance, use this style in diagnostic messages: "operand of a 'delete' operator" (single quotes) rather than old style: "operand of a delete operator" (single quotes) This is for consistency, as we use the new style in the privateIdentifiers error messages and it is consistent with our messages about other operators incorporate private names early exit feedback and code style change to use a ternary instead of if so we can 'const' require private-named fields to be declared in JS All fields must be declared in TS files. In JS files, we typically do not have this requirement. So special-case private fields, which must always be declared (even in JS files, per spec) update debug failure for es2015 private identifier Co-Authored-By: Ron Buckton <ron.buckton@microsoft.com> fix checker handling of private name in subclasse update checker and tests to account for the following ts features: - private names do not participate in the prototype chain, but *are* assigned in the parent class' constructor. So parent can access its *own* private fields on instances of the subclass Add more tests for private-named fields in JS add test to hit symbolToExpression w private names symbolToExpression knows about private names add a test to exercise this code path ban private-named static methods (not supported yet) ban private-named methods (not supported yet) ban private-named accessors (not supported yet) fix privateIdentifier fourslash test change assertion throw to return Co-Authored-By: Ron Buckton <ron.buckton@microsoft.com> Update comment in checker.ts re reserved members Remove case for privateIdentifier in EntityNameExpr Remove case for privateIdentifier in EntityNameExpr. That code path is never hit, and privateIdnetifiers cannot be entity names. remove unnecessary parentheses Ban private identifier in enum As the new test, 'privateNameEnumNoEmit', shows, the checker now correctly makes a diagnostic for private identifiers in enums. However, when noEmit is false we hit this assertion in the transformer. This assertion will have to be removed so that we have a diagnostic here instead of an assertion error. When the assertion is removed, the 'privateNameEnum' baseline will have to be updated Fix destructuring assignment, use createCallBinding, remove unneeded helper Add class private field helpers to external helpers Remove private identifier enum assertion, use missing identifiers Fix hash map inefficiency by only using get Update baselines with empty identifier change Add privateNameEnum test baselines Fix private identifier destructuring (array assignment defaults, unique names) Use createPrivateIdentifierAssignment in destructuring transform Fix lint error Separate destructuring target visitor from regular visitor Fix destructuring assignment with this bindings Fix destructuring assignment with this bindings Fix syntax error with destructuring assignment output Disallow private identifiers in property signatures remove duplicate test baselines Add tests for undeclarated private identifiers remove unnecessary cast Nicer error message for mis-placed hashbang Workaround v8 bug with destructured assignments Optimize private identifier stack lookup Avoid the cost of performing an array lookup to look at the top of the private identifier environment stack. Change function name to be more specific Changes "getOperatorForCompoundAssignment" to "getNonAssignmentOperatorForCompoundAssignment" now that this function is accessible to the entire compiler. Improve test case for private name assignment Adds a compound assignment test case for a class with private names being declared on the left-hand-side of the assignment expression. Remove extra non-private-field test Remove isPrivateIdentifierAssignmentExpression helper Don't transform private names in ESNext target Preserve private fields initialized to functions Move function expressions to outer scope for efficiency Add WeakMap collision check Modify potential WeakMap collision condition Fix this property assignment binding with private names Add correct error message for WeakMap collision Add error for statements before super with private identifiers Refactor getPropertyForPrivateIdentifier Add test for private identifier fields initialized to class exprs Fix shebang errors Fix private errors on index signatures Add codefix for missing private property Update error messages for unsupported private features Fix inheritance-related errors Fixes inheritance-related errors with private identifiers by resolving properties from base classes. Private identifiers do not show up as properties on a union type, so those do not type-check. Add test for interface extending class with private access Remove debugging log Remove name assignment from private named functions Rename to getPrivateIdentifierPropertyOfType Fix index signature test comment Fix test target syntax error Change error messages patch private identifiers outside class bodies Add test for private identifier with ooo super Add test for a class with a private identifier with a non-preambly (for example, not a comment) statement before 'super': should error, saying 'super' must come first Fix nits incorporate PR feedback Incorporate checker feedback - reorganize if statements in checkFunctionOrConstructorSymbol - remove overload for getPrivateIdentifierPropertyOfType reorganize if statements in checkFunctionOrConstructorSymbol test for private names with JSX use getPropertyOftype in getPropertyForPrivateIdentifier getPrivateIdentifierPropertyOfType error on synthetic make getPrivateIdentifierPropertyOfType error if given a node that is not from the parse tree Simplify checkPrivateIdentifierPropertyAccess use getPropertiesOfType instead of rehashing that logic test for private identifiers w decl merging fix test target for privateNameDeclarationMerging update baselines Fix private identifier ++/-- numeric coercion Remove 'downleveled' from super error Fix bad comments in helper call emit Error on private identifiers in JSX tag names Add more private identifier tests Add es2015 target for private name destructured binding test Add privateNameConstructorSignature test Add test for navigation bar w private identifier Remove spurious line from test // in js file class A { exports.#foo = 3; // should error } The above line failed to produce an error when run using the test harness. When using tsc or the language server, we got the expected error message. Removing the troublesome line, as it seems to say more about the test runner than about the code it is testing. Fix inefficient constructor generation dts: don't emit type for private-identified field Do not emit types for private-identified fields when generating declaration files. // example.ts export class A { #foo: number; } // example.d.ts export declare class A { #foo; } **This is not ideal!** The following would be better: // example.d.ts export declare unique class A { #foo; } See discussion: https://github.com/microsoft/TypeScript/pull/33038#issuecomment-530321165 notice when private-identified field unused Notice when private-identified fields are unused, and implement the same behavior as for unused private-modified fields. This is used in the language server to make things grayed out. This case generates an error when --noUnusedLocals flag is passed to tsc: - "<name> is declared but never used" accept baselines Revert "dts: don't emit type for private-identified field" This reverts commit e50305df5fb88121486291abad14478f5339a455. Instead of just excluding the type from private identifier emit, only emit a single private identifier per class. This accomplishes nominality while hiding implementation detail that is irrelevant to .d.ts consumers only emit a single private identifier in dts In dts emit, emit at most one private identifier, and rename it to `#private`. refactor getPrivateIdentifierPropertyOfType - safer check for wehther is parse tree node - return undefined when not found (instead of a Debug.fail) Incorporate PR feedback Don't rely on parent pointers in transform Passes context about whether the postfix unary expression value is discarded down the tree into the visitPostfixUnaryExpression function. Remove orphaned test baseline files remove unreachable if Check `any`-typed private identified fields Update private identifier incompatible modifier checks - disallow 'abstract' with private identifiers - s/private-named-property/private identifier Add additional call expression test cases Fix disallow 'abstract' with private identifier Static private identifiers not inherited Including this in the PR for private instance fields even though static private identifiers are banned. Reason: this change improves quality of error messages, see test case. Thanks Ron! Simplifiy private identifier 'any' type handling Error on private identifier declarations for ES5/ES3 Bind `this` for private identifier property tagged template literals Fix target for jsdocPrivateName1 test Update getPrivateIdentifierPropertyOfType API Make it easier to use by accepting a string and location, rather than a PrivateIdentifier. Thanks Ron! remove orphaned tests rename test remove duplicate tests Remove unrelated error from test update diagnostic message 'private identifier' The nodes for hash private fields are now called 'private identifier'. Update one last diagnostic message to use the new terminology. refine solution for static private identifier fields - use `continue` instead of `filter` for perf - better naming - make it clear the current solution will need to be altered when we lift the ban on static private identifier fields, including a test case that should change in the future Fix display of private identifiers in lang server Fix bug where private identifiers in completion tooltips in the playground were showing up as the symbol table entries (with underscores and such). https://github.com/microsoft/TypeScript/pull/30829#issuecomment-534157560 Signed-off-by: Max Heiber <max.heiber@gmail.com> * fix privateIdentifier w !useDefineForClassFields Signed-off-by: Max Heiber <max.heiber@gmail.com> * Disallow PrivateIdentifier in Optional Chains Signed-off-by: Max Heiber <max.heiber@gmail.com> * restrict privateIdentifier completions correctly Don't autocomplete privateIdentifiers in places where they are not allowed. Signed-off-by: Max Heiber <max.heiber@gmail.com> * make PrivateIdentifier not a PropertyNameLiteral Signed-off-by: Max Heiber <max.heiber@gmail.com> * Added test. * Accepted baselines. * Update symbol serializer to understand private fields in JS `.d.ts` emit. * Accepted baselines. * fix for private field no initializer esnext Signed-off-by: Max Heiber <max.heiber@gmail.com> * fix private fields .d.ts emit for JS w expando fix bug where the following in a JS file would lead to a `#private` in the .d.ts: ```js class C { constructor () { this.a = 3 } } ``` Co-authored-by: Joey Watts <joey.watts.96@gmail.com> Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
committed by
Daniel Rosenwasser
co-authored by
Joey Watts
Daniel Rosenwasser
parent
0f5ddd2ea0
commit
36c87aca8a
+41
-3
@@ -359,6 +359,16 @@ namespace ts {
|
||||
if (isWellKnownSymbolSyntactically(name)) {
|
||||
return getPropertyNameForKnownSymbolName(idText(name.name));
|
||||
}
|
||||
if (isPrivateIdentifier(name)) {
|
||||
// containingClass exists because private names only allowed inside classes
|
||||
const containingClass = getContainingClass(node);
|
||||
if (!containingClass) {
|
||||
// we can get here in cases where there is already a parse error.
|
||||
return undefined;
|
||||
}
|
||||
const containingClassSymbol = containingClass.symbol;
|
||||
return getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
|
||||
}
|
||||
return isPropertyNameLiteral(name) ? getEscapedTextOfIdentifierOrLiteral(name) : undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
@@ -471,7 +481,6 @@ namespace ts {
|
||||
if (isNamedDeclaration(node)) {
|
||||
node.name.parent = node;
|
||||
}
|
||||
|
||||
// Report errors every position with duplicate declaration
|
||||
// Report errors on previous encountered declarations
|
||||
let message = symbol.flags & SymbolFlags.BlockScopedVariable
|
||||
@@ -1599,7 +1608,7 @@ namespace ts {
|
||||
}
|
||||
if (node.expression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
const propertyAccess = <PropertyAccessExpression>node.expression;
|
||||
if (isNarrowableOperand(propertyAccess.expression) && isPushOrUnshiftIdentifier(propertyAccess.name)) {
|
||||
if (isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && isPushOrUnshiftIdentifier(propertyAccess.name)) {
|
||||
currentFlow = createFlowMutation(FlowFlags.ArrayMutation, currentFlow, node);
|
||||
}
|
||||
}
|
||||
@@ -2026,6 +2035,18 @@ namespace ts {
|
||||
return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode;
|
||||
}
|
||||
|
||||
// The binder visits every node, so this is a good place to check for
|
||||
// the reserved private name (there is only one)
|
||||
function checkPrivateIdentifier(node: PrivateIdentifier) {
|
||||
if (node.escapedText === "#constructor") {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node,
|
||||
Diagnostics.constructor_is_a_reserved_word, declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkStrictModeBinaryExpression(node: BinaryExpression) {
|
||||
if (inStrictMode && isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operatorToken.kind)) {
|
||||
// ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an
|
||||
@@ -2298,6 +2319,8 @@ namespace ts {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
return checkStrictModeIdentifier(<Identifier>node);
|
||||
case SyntaxKind.PrivateIdentifier:
|
||||
return checkPrivateIdentifier(node as PrivateIdentifier);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
const expr = node as PropertyAccessExpression | ElementAccessExpression;
|
||||
@@ -2657,6 +2680,12 @@ namespace ts {
|
||||
|
||||
function bindThisPropertyAssignment(node: BindablePropertyAssignmentExpression | PropertyAccessExpression | LiteralLikeElementAccessExpression) {
|
||||
Debug.assert(isInJSFile(node));
|
||||
// private identifiers *must* be declared (even in JS files)
|
||||
const hasPrivateIdentifier = (isBinaryExpression(node) && isPropertyAccessExpression(node.left) && isPrivateIdentifier(node.left.name))
|
||||
|| (isPropertyAccessExpression(node) && isPrivateIdentifier(node.name));
|
||||
if (hasPrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
const thisContainer = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
switch (thisContainer.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
@@ -2959,7 +2988,12 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
const s = forEachIdentifierInEntityName(e.expression, parent, action);
|
||||
return action(getNameOrArgument(e), s && s.exports && s.exports.get(getElementOrPropertyAccessName(e)), s);
|
||||
const name = getNameOrArgument(e);
|
||||
// unreachable
|
||||
if (isPrivateIdentifier(name)) {
|
||||
Debug.fail("unexpected PrivateIdentifier");
|
||||
}
|
||||
return action(name, s && s.exports && s.exports.get(getElementOrPropertyAccessName(e)), s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4131,6 +4165,10 @@ namespace ts {
|
||||
case SyntaxKind.BreakStatement:
|
||||
transformFlags |= TransformFlags.ContainsHoistedDeclarationOrCompletion;
|
||||
break;
|
||||
|
||||
case SyntaxKind.PrivateIdentifier:
|
||||
transformFlags |= TransformFlags.ContainsClassFields;
|
||||
break;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
|
||||
+436
-139
File diff suppressed because it is too large
Load Diff
@@ -1397,7 +1397,7 @@
|
||||
"category": "Error",
|
||||
"code": 2375
|
||||
},
|
||||
"A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": {
|
||||
"A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.": {
|
||||
"category": "Error",
|
||||
"code": 2376
|
||||
},
|
||||
@@ -2479,11 +2479,11 @@
|
||||
"category": "Error",
|
||||
"code": 2702
|
||||
},
|
||||
"The operand of a delete operator must be a property reference.": {
|
||||
"The operand of a 'delete' operator must be a property reference.": {
|
||||
"category": "Error",
|
||||
"code": 2703
|
||||
},
|
||||
"The operand of a delete operator cannot be a read-only property.": {
|
||||
"The operand of a 'delete' operator cannot be a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2704
|
||||
},
|
||||
@@ -5361,5 +5361,85 @@
|
||||
"JSX expressions may not use the comma operator. Did you mean to write an array?": {
|
||||
"category": "Error",
|
||||
"code": 18007
|
||||
},
|
||||
"'#!' can only be used at the start of a file.": {
|
||||
"category": "Error",
|
||||
"code": 18008
|
||||
},
|
||||
"Private identifiers cannot be used as parameters": {
|
||||
"category": "Error",
|
||||
"code": 18009
|
||||
},
|
||||
"An accessibility modifier cannot be used with a private identifier.": {
|
||||
"category": "Error",
|
||||
"code": 18010
|
||||
},
|
||||
"The operand of a 'delete' operator cannot be a private identifier.": {
|
||||
"category": "Error",
|
||||
"code": 18011
|
||||
},
|
||||
"'#constructor' is a reserved word.": {
|
||||
"category": "Error",
|
||||
"code": 18012
|
||||
},
|
||||
"Property '{0}' is not accessible outside class '{1}' because it has a private identifier.": {
|
||||
"category": "Error",
|
||||
"code": 18013
|
||||
},
|
||||
"The property '{0}' cannot be accessed on type '{1}' within this class because it is shadowed by another private identifier with the same spelling.": {
|
||||
"category": "Error",
|
||||
"code": 18014
|
||||
},
|
||||
"Property '{0}' in type '{1}' refers to a different member that cannot be accessed from within type '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 18015
|
||||
},
|
||||
"Private identifiers are not allowed outside class bodies.": {
|
||||
"category": "Error",
|
||||
"code": 18016
|
||||
},
|
||||
"The shadowing declaration of '{0}' is defined here": {
|
||||
"category": "Error",
|
||||
"code": 18017
|
||||
},
|
||||
"The declaration of '{0}' that you probably intended to use is defined here": {
|
||||
"category": "Error",
|
||||
"code": 18018
|
||||
},
|
||||
"'{0}' modifier cannot be used with a private identifier": {
|
||||
"category": "Error",
|
||||
"code": 18019
|
||||
},
|
||||
"A method cannot be named with a private identifier.": {
|
||||
"category": "Error",
|
||||
"code": 18022
|
||||
},
|
||||
"An accessor cannot be named with a private identifier.": {
|
||||
"category": "Error",
|
||||
"code": 18023
|
||||
},
|
||||
"An enum member cannot be named with a private identifier.": {
|
||||
"category": "Error",
|
||||
"code": 18024
|
||||
},
|
||||
"'#!' can only be used at the start of a file.": {
|
||||
"category": "Error",
|
||||
"code": 18026
|
||||
},
|
||||
"Compiler reserves name '{0}' when emitting private identifier downlevel.": {
|
||||
"category": "Error",
|
||||
"code": 18027
|
||||
},
|
||||
"Private identifiers are only available when targeting ECMAScript 2015 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 18028
|
||||
},
|
||||
"Private identifiers are not allowed in variable declarations.": {
|
||||
"category": "Error",
|
||||
"code": 18029
|
||||
},
|
||||
"An optional chain cannot contain private identifiers.": {
|
||||
"category": "Error",
|
||||
"code": 18030
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -1253,6 +1253,10 @@ namespace ts {
|
||||
case SyntaxKind.Identifier:
|
||||
return emitIdentifier(<Identifier>node);
|
||||
|
||||
// PrivateIdentifiers
|
||||
case SyntaxKind.PrivateIdentifier:
|
||||
return emitPrivateIdentifier(node as PrivateIdentifier);
|
||||
|
||||
// Parse tree nodes
|
||||
// Names
|
||||
case SyntaxKind.QualifiedName:
|
||||
@@ -1818,6 +1822,12 @@ namespace ts {
|
||||
// Names
|
||||
//
|
||||
|
||||
function emitPrivateIdentifier(node: PrivateIdentifier) {
|
||||
const writeText = node.symbol ? writeSymbol : write;
|
||||
writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol);
|
||||
}
|
||||
|
||||
|
||||
function emitQualifiedName(node: QualifiedName) {
|
||||
emitEntityName(node.left);
|
||||
writePunctuation(".");
|
||||
@@ -4285,7 +4295,7 @@ namespace ts {
|
||||
if (isGeneratedIdentifier(node)) {
|
||||
return generateName(node);
|
||||
}
|
||||
else if (isIdentifier(node) && (nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && getSourceFileOfNode(node) !== getOriginalNode(currentSourceFile)))) {
|
||||
else if ((isIdentifier(node) || isPrivateIdentifier(node)) && (nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && getSourceFileOfNode(node) !== getOriginalNode(currentSourceFile)))) {
|
||||
return idText(node);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.StringLiteral && (<StringLiteral>node).textSourceNode) {
|
||||
|
||||
+19
-7
@@ -37,7 +37,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
const expression = setTextRange(
|
||||
isIdentifier(memberName)
|
||||
(isIdentifier(memberName) || isPrivateIdentifier(memberName))
|
||||
? createPropertyAccess(target, memberName)
|
||||
: createElementAccess(target, memberName),
|
||||
memberName
|
||||
@@ -501,7 +501,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function createExpressionForPropertyName(memberName: PropertyName): Expression {
|
||||
export function createExpressionForPropertyName(memberName: Exclude<PropertyName, PrivateIdentifier>): Expression {
|
||||
if (isIdentifier(memberName)) {
|
||||
return createLiteral(memberName);
|
||||
}
|
||||
@@ -514,10 +514,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createExpressionForObjectLiteralElementLike(node: ObjectLiteralExpression, property: ObjectLiteralElementLike, receiver: Expression): Expression | undefined {
|
||||
if (property.name && isPrivateIdentifier(property.name)) {
|
||||
Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals.");
|
||||
}
|
||||
switch (property.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine);
|
||||
return createExpressionForAccessorDeclaration(node.properties, property as typeof property & { name: Exclude<PropertyName, PrivateIdentifier>; }, receiver, !!node.multiLine);
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return createExpressionForPropertyAssignment(property, receiver);
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
@@ -527,7 +530,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function createExpressionForAccessorDeclaration(properties: NodeArray<Declaration>, property: AccessorDeclaration, receiver: Expression, multiLine: boolean) {
|
||||
function createExpressionForAccessorDeclaration(properties: NodeArray<Declaration>, property: AccessorDeclaration & { name: Exclude<PropertyName, PrivateIdentifier>; }, receiver: Expression, multiLine: boolean) {
|
||||
const { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(properties, property);
|
||||
if (property === firstAccessor) {
|
||||
const properties: ObjectLiteralElementLike[] = [];
|
||||
@@ -1740,13 +1743,13 @@ namespace ts {
|
||||
/**
|
||||
* Gets the property name of a BindingOrAssignmentElement
|
||||
*/
|
||||
export function getPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): PropertyName | undefined {
|
||||
export function getPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): Exclude<PropertyName, PrivateIdentifier> | undefined {
|
||||
const propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement);
|
||||
Debug.assert(!!propertyName || isSpreadAssignment(bindingElement), "Invalid property name for binding element.");
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
export function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): PropertyName | undefined {
|
||||
export function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): Exclude<PropertyName, PrivateIdentifier> | undefined {
|
||||
switch (bindingElement.kind) {
|
||||
case SyntaxKind.BindingElement:
|
||||
// `a` in `let { a: b } = ...`
|
||||
@@ -1755,6 +1758,9 @@ namespace ts {
|
||||
// `1` in `let { 1: b } = ...`
|
||||
if (bindingElement.propertyName) {
|
||||
const propertyName = bindingElement.propertyName;
|
||||
if (isPrivateIdentifier(propertyName)) {
|
||||
return Debug.failBadSyntaxKind(propertyName);
|
||||
}
|
||||
return isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
|
||||
? propertyName.expression
|
||||
: propertyName;
|
||||
@@ -1769,6 +1775,9 @@ namespace ts {
|
||||
// `1` in `({ 1: b } = ...)`
|
||||
if (bindingElement.name) {
|
||||
const propertyName = bindingElement.name;
|
||||
if (isPrivateIdentifier(propertyName)) {
|
||||
return Debug.failBadSyntaxKind(propertyName);
|
||||
}
|
||||
return isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
|
||||
? propertyName.expression
|
||||
: propertyName;
|
||||
@@ -1778,6 +1787,9 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
// `a` in `({ ...a } = ...)`
|
||||
if (bindingElement.name && isPrivateIdentifier(bindingElement.name)) {
|
||||
return Debug.failBadSyntaxKind(bindingElement.name);
|
||||
}
|
||||
return bindingElement.name;
|
||||
}
|
||||
|
||||
@@ -1899,4 +1911,4 @@ namespace ts {
|
||||
Debug.assertNode(node, isExpression);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
function createLiteralFromNode(sourceNode: PropertyNameLiteral): StringLiteral {
|
||||
function createLiteralFromNode(sourceNode: Exclude<PropertyNameLiteral, PrivateIdentifier>): StringLiteral {
|
||||
const node = createStringLiteral(getTextOfIdentifierOrLiteral(sourceNode));
|
||||
node.textSourceNode = sourceNode;
|
||||
return node;
|
||||
@@ -216,6 +216,13 @@ namespace ts {
|
||||
return name;
|
||||
}
|
||||
|
||||
// Private Identifiers
|
||||
export function createPrivateIdentifier(text: string): PrivateIdentifier {
|
||||
const node = createSynthesizedNode(SyntaxKind.PrivateIdentifier) as PrivateIdentifier;
|
||||
node.escapedText = escapeLeadingUnderscores(text);
|
||||
return node;
|
||||
}
|
||||
|
||||
// Punctuation
|
||||
|
||||
export function createToken<TKind extends SyntaxKind>(token: TKind) {
|
||||
@@ -1057,7 +1064,7 @@ namespace ts {
|
||||
: node;
|
||||
}
|
||||
|
||||
export function createPropertyAccess(expression: Expression, name: string | Identifier) {
|
||||
export function createPropertyAccess(expression: Expression, name: string | Identifier | PrivateIdentifier) {
|
||||
const node = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
|
||||
node.expression = parenthesizeForAccess(expression);
|
||||
node.name = asName(name);
|
||||
@@ -1065,9 +1072,11 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier) {
|
||||
if (isOptionalChain(node)) {
|
||||
return updatePropertyAccessChain(node, expression, node.questionDotToken, name);
|
||||
export function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier) {
|
||||
if (isOptionalChain(node) && isIdentifier(node.name) && isIdentifier(name)) {
|
||||
// Not sure why this cast was necessary: the previous line should already establish that node.name is an identifier
|
||||
const theNode = node as (typeof node & { name: Identifier });
|
||||
return updatePropertyAccessChain(theNode, expression, node.questionDotToken, name);
|
||||
}
|
||||
// Because we are updating existed propertyAccess we want to inherit its emitFlags
|
||||
// instead of using the default from createPropertyAccess
|
||||
@@ -2923,7 +2932,9 @@ namespace ts {
|
||||
templateObjectHelper,
|
||||
generatorHelper,
|
||||
importStarHelper,
|
||||
importDefaultHelper
|
||||
importDefaultHelper,
|
||||
classPrivateFieldGetHelper,
|
||||
classPrivateFieldSetHelper,
|
||||
], helper => helper.name));
|
||||
}
|
||||
|
||||
|
||||
+39
-5
@@ -11,6 +11,7 @@ namespace ts {
|
||||
let NodeConstructor: new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
let TokenConstructor: new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
let IdentifierConstructor: new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
let PrivateIdentifierConstructor: new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
let SourceFileConstructor: new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
|
||||
export function createNode(kind: SyntaxKind, pos?: number, end?: number): Node {
|
||||
@@ -20,6 +21,9 @@ namespace ts {
|
||||
else if (kind === SyntaxKind.Identifier) {
|
||||
return new (IdentifierConstructor || (IdentifierConstructor = objectAllocator.getIdentifierConstructor()))(kind, pos, end);
|
||||
}
|
||||
else if (kind === SyntaxKind.PrivateIdentifier) {
|
||||
return new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = objectAllocator.getPrivateIdentifierConstructor()))(kind, pos, end);
|
||||
}
|
||||
else if (!isNodeKind(kind)) {
|
||||
return new (TokenConstructor || (TokenConstructor = objectAllocator.getTokenConstructor()))(kind, pos, end);
|
||||
}
|
||||
@@ -602,6 +606,7 @@ namespace ts {
|
||||
let NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
|
||||
let TokenConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
|
||||
let IdentifierConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
|
||||
let PrivateIdentifierConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
|
||||
let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
|
||||
|
||||
let sourceFile: SourceFile;
|
||||
@@ -612,6 +617,7 @@ namespace ts {
|
||||
let sourceText: string;
|
||||
let nodeCount: number;
|
||||
let identifiers: Map<string>;
|
||||
let privateIdentifiers: Map<string>;
|
||||
let identifierCount: number;
|
||||
|
||||
let parsingContext: ParsingContext;
|
||||
@@ -800,6 +806,7 @@ namespace ts {
|
||||
NodeConstructor = objectAllocator.getNodeConstructor();
|
||||
TokenConstructor = objectAllocator.getTokenConstructor();
|
||||
IdentifierConstructor = objectAllocator.getIdentifierConstructor();
|
||||
PrivateIdentifierConstructor = objectAllocator.getPrivateIdentifierConstructor();
|
||||
SourceFileConstructor = objectAllocator.getSourceFileConstructor();
|
||||
|
||||
sourceText = _sourceText;
|
||||
@@ -808,6 +815,7 @@ namespace ts {
|
||||
parseDiagnostics = [];
|
||||
parsingContext = 0;
|
||||
identifiers = createMap<string>();
|
||||
privateIdentifiers = createMap<string>();
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
|
||||
@@ -1321,6 +1329,7 @@ namespace ts {
|
||||
const p = pos! >= 0 ? pos! : scanner.getStartPos();
|
||||
return isNodeKind(kind) || kind === SyntaxKind.Unknown ? new NodeConstructor(kind, p, p) :
|
||||
kind === SyntaxKind.Identifier ? new IdentifierConstructor(kind, p, p) :
|
||||
kind === SyntaxKind.PrivateIdentifier ? new PrivateIdentifierConstructor(kind, p, p) :
|
||||
new TokenConstructor(kind, p, p);
|
||||
}
|
||||
|
||||
@@ -1444,6 +1453,9 @@ namespace ts {
|
||||
if (allowComputedPropertyNames && token() === SyntaxKind.OpenBracketToken) {
|
||||
return parseComputedPropertyName();
|
||||
}
|
||||
if (token() === SyntaxKind.PrivateIdentifier) {
|
||||
return parsePrivateIdentifier();
|
||||
}
|
||||
return parseIdentifierName();
|
||||
}
|
||||
|
||||
@@ -1467,6 +1479,21 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function internPrivateIdentifier(text: string): string {
|
||||
let privateIdentifier = privateIdentifiers.get(text);
|
||||
if (privateIdentifier === undefined) {
|
||||
privateIdentifiers.set(text, privateIdentifier = text);
|
||||
}
|
||||
return privateIdentifier;
|
||||
}
|
||||
|
||||
function parsePrivateIdentifier(): PrivateIdentifier {
|
||||
const node = createNode(SyntaxKind.PrivateIdentifier) as PrivateIdentifier;
|
||||
node.escapedText = escapeLeadingUnderscores(internPrivateIdentifier(scanner.getTokenText()));
|
||||
nextToken();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseContextualModifier(t: SyntaxKind): boolean {
|
||||
return token() === t && tryParse(nextTokenCanFollowModifier);
|
||||
}
|
||||
@@ -2228,7 +2255,7 @@ namespace ts {
|
||||
break;
|
||||
}
|
||||
dotPos = scanner.getStartPos();
|
||||
entity = createQualifiedName(entity, parseRightSideOfDot(allowReservedWords));
|
||||
entity = createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false) as Identifier);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
@@ -2240,7 +2267,7 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseRightSideOfDot(allowIdentifierNames: boolean): Identifier {
|
||||
function parseRightSideOfDot(allowIdentifierNames: boolean, allowPrivateIdentifiers: boolean): Identifier | PrivateIdentifier {
|
||||
// Technically a keyword is valid here as all identifiers and keywords are identifier names.
|
||||
// However, often we'll encounter this in error situations when the identifier or keyword
|
||||
// is actually starting another valid construct.
|
||||
@@ -2271,6 +2298,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (token() === SyntaxKind.PrivateIdentifier) {
|
||||
const node = parsePrivateIdentifier();
|
||||
return allowPrivateIdentifiers ? node : createMissingNode<Identifier>(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Identifier_expected);
|
||||
}
|
||||
|
||||
return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
|
||||
}
|
||||
|
||||
@@ -4344,7 +4376,8 @@ namespace ts {
|
||||
const node = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
|
||||
node.expression = expression;
|
||||
parseExpectedToken(SyntaxKind.DotToken, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
|
||||
node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
|
||||
// private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic
|
||||
node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
@@ -4515,7 +4548,7 @@ namespace ts {
|
||||
while (parseOptional(SyntaxKind.DotToken)) {
|
||||
const propertyAccess: JsxTagNamePropertyAccess = <JsxTagNamePropertyAccess>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
|
||||
propertyAccess.expression = expression;
|
||||
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
|
||||
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false);
|
||||
expression = finishNode(propertyAccess);
|
||||
}
|
||||
return expression;
|
||||
@@ -4632,7 +4665,8 @@ namespace ts {
|
||||
const propertyAccess = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
|
||||
propertyAccess.expression = expression;
|
||||
propertyAccess.questionDotToken = questionDotToken;
|
||||
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
|
||||
// checker will error on private identifiers in optional chains, so don't have to catch them here
|
||||
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true);
|
||||
if (questionDotToken || expression.flags & NodeFlags.OptionalChain) {
|
||||
propertyAccess.flags |= NodeFlags.OptionalChain;
|
||||
}
|
||||
|
||||
@@ -1893,6 +1893,25 @@ namespace ts {
|
||||
error(Diagnostics.Invalid_character);
|
||||
pos++;
|
||||
return token = SyntaxKind.Unknown;
|
||||
case CharacterCodes.hash:
|
||||
if (pos !== 0 && text[pos + 1] === "!") {
|
||||
error(Diagnostics.can_only_be_used_at_the_start_of_a_file);
|
||||
pos++;
|
||||
return token = SyntaxKind.Unknown;
|
||||
}
|
||||
pos++;
|
||||
if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) {
|
||||
pos++;
|
||||
while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++;
|
||||
tokenValue = text.substring(tokenPos, pos);
|
||||
if (ch === CharacterCodes.backslash) {
|
||||
tokenValue += scanIdentifierParts();
|
||||
}
|
||||
return token = SyntaxKind.PrivateIdentifier;
|
||||
}
|
||||
error(Diagnostics.Invalid_character);
|
||||
// no `pos++` because already advanced past the '#'
|
||||
return token = SyntaxKind.Unknown;
|
||||
default:
|
||||
if (isIdentifierStart(ch, languageVersion)) {
|
||||
pos += charSize(ch);
|
||||
|
||||
@@ -7,6 +7,23 @@ namespace ts {
|
||||
*/
|
||||
ClassAliases = 1 << 0,
|
||||
}
|
||||
|
||||
const enum PrivateIdentifierPlacement {
|
||||
InstanceField
|
||||
}
|
||||
|
||||
type PrivateIdentifierInfo = PrivateIdentifierInstanceField;
|
||||
|
||||
interface PrivateIdentifierInstanceField {
|
||||
placement: PrivateIdentifierPlacement.InstanceField;
|
||||
weakMapName: Identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* A mapping of private names to information needed for transformation.
|
||||
*/
|
||||
type PrivateIdentifierEnvironment = UnderscoreEscapedMap<PrivateIdentifierInfo>;
|
||||
|
||||
/**
|
||||
* Transforms ECMAScript Class Syntax.
|
||||
* TypeScript parameter property syntax is transformed in the TypeScript transformer.
|
||||
@@ -21,6 +38,10 @@ namespace ts {
|
||||
resumeLexicalEnvironment
|
||||
} = context;
|
||||
const resolver = context.getEmitResolver();
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
|
||||
const shouldTransformPrivateFields = languageVersion < ScriptTarget.ESNext;
|
||||
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
@@ -41,6 +62,9 @@ namespace ts {
|
||||
*/
|
||||
let pendingStatements: Statement[] | undefined;
|
||||
|
||||
const privateIdentifierEnvironmentStack: (PrivateIdentifierEnvironment | undefined)[] = [];
|
||||
let currentPrivateIdentifierEnvironment: PrivateIdentifierEnvironment | undefined;
|
||||
|
||||
return chainBundle(transformSourceFile);
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
@@ -59,15 +83,57 @@ namespace ts {
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassExpression:
|
||||
return visitClassExpression(node as ClassExpression);
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return visitClassDeclaration(node as ClassDeclaration);
|
||||
return visitClassLike(node as ClassLikeDeclaration);
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
return visitPropertyDeclaration(node as PropertyDeclaration);
|
||||
case SyntaxKind.VariableStatement:
|
||||
return visitVariableStatement(node as VariableStatement);
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return visitComputedPropertyName(node as ComputedPropertyName);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return visitPropertyAccessExpression(node as PropertyAccessExpression);
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
return visitPrefixUnaryExpression(node as PrefixUnaryExpression);
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
return visitPostfixUnaryExpression(node as PostfixUnaryExpression, /*valueIsDiscarded*/ false);
|
||||
case SyntaxKind.CallExpression:
|
||||
return visitCallExpression(node as CallExpression);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return visitBinaryExpression(node as BinaryExpression);
|
||||
case SyntaxKind.PrivateIdentifier:
|
||||
return visitPrivateIdentifier(node as PrivateIdentifier);
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
return visitExpressionStatement(node as ExpressionStatement);
|
||||
case SyntaxKind.ForStatement:
|
||||
return visitForStatement(node as ForStatement);
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
return visitTaggedTemplateExpression(node as TaggedTemplateExpression);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitorDestructuringTarget(node: Node): VisitResult<Node> {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return visitAssignmentPattern(node as AssignmentPattern);
|
||||
default:
|
||||
return visitor(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If we visit a private name, this means it is an undeclared private name.
|
||||
* Replace it with an empty identifier to indicate a problem with the code.
|
||||
*/
|
||||
function visitPrivateIdentifier(node: PrivateIdentifier) {
|
||||
if (!shouldTransformPrivateFields) {
|
||||
return node;
|
||||
}
|
||||
return setOriginalNode(createIdentifier(""), node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the members of a class that has fields.
|
||||
*
|
||||
@@ -129,6 +195,18 @@ namespace ts {
|
||||
|
||||
function visitPropertyDeclaration(node: PropertyDeclaration) {
|
||||
Debug.assert(!some(node.decorators));
|
||||
if (!shouldTransformPrivateFields && isPrivateIdentifier(node.name)) {
|
||||
// Initializer is elided as the field is initialized in transformConstructor.
|
||||
return updateProperty(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
visitNodes(node.modifiers, visitor, isModifier),
|
||||
node.name,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
/*initializer*/ undefined
|
||||
);
|
||||
}
|
||||
// Create a temporary variable to store a computed property name (if necessary).
|
||||
// If it's not inlineable, then we emit an expression after the class which assigns
|
||||
// the property name to the temporary variable.
|
||||
@@ -139,13 +217,244 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function visitClassDeclaration(node: ClassDeclaration) {
|
||||
if (!forEach(node.members, isPropertyDeclaration)) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
function createPrivateIdentifierAccess(info: PrivateIdentifierInfo, receiver: Expression): Expression {
|
||||
receiver = visitNode(receiver, visitor, isExpression);
|
||||
switch (info.placement) {
|
||||
case PrivateIdentifierPlacement.InstanceField:
|
||||
return createClassPrivateFieldGetHelper(
|
||||
context,
|
||||
nodeIsSynthesized(receiver) ? receiver : getSynthesizedClone(receiver),
|
||||
info.weakMapName
|
||||
);
|
||||
default: return Debug.fail("Unexpected private identifier placement");
|
||||
}
|
||||
}
|
||||
|
||||
function visitPropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (shouldTransformPrivateFields && isPrivateIdentifier(node.name)) {
|
||||
const privateIdentifierInfo = accessPrivateIdentifier(node.name);
|
||||
if (privateIdentifierInfo) {
|
||||
return setOriginalNode(
|
||||
createPrivateIdentifierAccess(privateIdentifierInfo, node.expression),
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitPrefixUnaryExpression(node: PrefixUnaryExpression) {
|
||||
if (shouldTransformPrivateFields && isPrivateIdentifierPropertyAccessExpression(node.operand)) {
|
||||
const operator = node.operator === SyntaxKind.PlusPlusToken ?
|
||||
SyntaxKind.PlusToken : node.operator === SyntaxKind.MinusMinusToken ?
|
||||
SyntaxKind.MinusToken : undefined;
|
||||
let info: PrivateIdentifierInfo | undefined;
|
||||
if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
|
||||
const receiver = visitNode(node.operand.expression, visitor, isExpression);
|
||||
const { readExpression, initializeExpression } = createCopiableReceiverExpr(receiver);
|
||||
|
||||
const existingValue = createPrefix(SyntaxKind.PlusToken, createPrivateIdentifierAccess(info, readExpression));
|
||||
|
||||
return setOriginalNode(
|
||||
createPrivateIdentifierAssignment(
|
||||
info,
|
||||
initializeExpression || readExpression,
|
||||
createBinary(existingValue, operator, createLiteral(1)),
|
||||
SyntaxKind.EqualsToken
|
||||
),
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitPostfixUnaryExpression(node: PostfixUnaryExpression, valueIsDiscarded: boolean) {
|
||||
if (shouldTransformPrivateFields && isPrivateIdentifierPropertyAccessExpression(node.operand)) {
|
||||
const operator = node.operator === SyntaxKind.PlusPlusToken ?
|
||||
SyntaxKind.PlusToken : node.operator === SyntaxKind.MinusMinusToken ?
|
||||
SyntaxKind.MinusToken : undefined;
|
||||
let info: PrivateIdentifierInfo | undefined;
|
||||
if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
|
||||
const receiver = visitNode(node.operand.expression, visitor, isExpression);
|
||||
const { readExpression, initializeExpression } = createCopiableReceiverExpr(receiver);
|
||||
|
||||
const existingValue = createPrefix(SyntaxKind.PlusToken, createPrivateIdentifierAccess(info, readExpression));
|
||||
|
||||
// Create a temporary variable to store the value returned by the expression.
|
||||
const returnValue = valueIsDiscarded ? undefined : createTempVariable(hoistVariableDeclaration);
|
||||
|
||||
return setOriginalNode(
|
||||
inlineExpressions(compact<Expression>([
|
||||
createPrivateIdentifierAssignment(
|
||||
info,
|
||||
initializeExpression || readExpression,
|
||||
createBinary(
|
||||
returnValue ? createAssignment(returnValue, existingValue) : existingValue,
|
||||
operator,
|
||||
createLiteral(1)
|
||||
),
|
||||
SyntaxKind.EqualsToken
|
||||
),
|
||||
returnValue
|
||||
])),
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitForStatement(node: ForStatement) {
|
||||
if (node.incrementor && isPostfixUnaryExpression(node.incrementor)) {
|
||||
return updateFor(
|
||||
node,
|
||||
visitNode(node.initializer, visitor, isForInitializer),
|
||||
visitNode(node.condition, visitor, isExpression),
|
||||
visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true),
|
||||
visitNode(node.statement, visitor, isStatement)
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitExpressionStatement(node: ExpressionStatement) {
|
||||
if (isPostfixUnaryExpression(node.expression)) {
|
||||
return updateExpressionStatement(node, visitPostfixUnaryExpression(node.expression, /*valueIsDiscarded*/ true));
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function createCopiableReceiverExpr(receiver: Expression): { readExpression: Expression; initializeExpression: Expression | undefined } {
|
||||
const clone = nodeIsSynthesized(receiver) ? receiver : getSynthesizedClone(receiver);
|
||||
if (isSimpleInlineableExpression(receiver)) {
|
||||
return { readExpression: clone, initializeExpression: undefined };
|
||||
}
|
||||
const readExpression = createTempVariable(hoistVariableDeclaration);
|
||||
const initializeExpression = createAssignment(readExpression, clone);
|
||||
return { readExpression, initializeExpression };
|
||||
}
|
||||
|
||||
function visitCallExpression(node: CallExpression) {
|
||||
if (shouldTransformPrivateFields && isPrivateIdentifierPropertyAccessExpression(node.expression)) {
|
||||
// Transform call expressions of private names to properly bind the `this` parameter.
|
||||
const { thisArg, target } = createCallBinding(node.expression, hoistVariableDeclaration, languageVersion);
|
||||
return updateCall(
|
||||
node,
|
||||
createPropertyAccess(visitNode(target, visitor), "call"),
|
||||
/*typeArguments*/ undefined,
|
||||
[visitNode(thisArg, visitor, isExpression), ...visitNodes(node.arguments, visitor, isExpression)]
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitTaggedTemplateExpression(node: TaggedTemplateExpression) {
|
||||
if (shouldTransformPrivateFields && isPrivateIdentifierPropertyAccessExpression(node.tag)) {
|
||||
// Bind the `this` correctly for tagged template literals when the tag is a private identifier property access.
|
||||
const { thisArg, target } = createCallBinding(node.tag, hoistVariableDeclaration, languageVersion);
|
||||
return updateTaggedTemplate(
|
||||
node,
|
||||
createCall(
|
||||
createPropertyAccess(visitNode(target, visitor), "bind"),
|
||||
/*typeArguments*/ undefined,
|
||||
[visitNode(thisArg, visitor, isExpression)]
|
||||
),
|
||||
visitNode(node.template, visitor, isTemplateLiteral)
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitBinaryExpression(node: BinaryExpression) {
|
||||
if (shouldTransformPrivateFields) {
|
||||
if (isDestructuringAssignment(node)) {
|
||||
const savedPendingExpressions = pendingExpressions;
|
||||
pendingExpressions = undefined!;
|
||||
node = updateBinary(
|
||||
node,
|
||||
visitNode(node.left, visitorDestructuringTarget),
|
||||
visitNode(node.right, visitor),
|
||||
node.operatorToken
|
||||
);
|
||||
const expr = some(pendingExpressions) ?
|
||||
inlineExpressions(compact([...pendingExpressions!, node])) :
|
||||
node;
|
||||
pendingExpressions = savedPendingExpressions;
|
||||
return expr;
|
||||
}
|
||||
if (isAssignmentExpression(node) && isPrivateIdentifierPropertyAccessExpression(node.left)) {
|
||||
const info = accessPrivateIdentifier(node.left.name);
|
||||
if (info) {
|
||||
return setOriginalNode(
|
||||
createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind),
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function createPrivateIdentifierAssignment(info: PrivateIdentifierInfo, receiver: Expression, right: Expression, operator: AssignmentOperator) {
|
||||
switch (info.placement) {
|
||||
case PrivateIdentifierPlacement.InstanceField: {
|
||||
return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator);
|
||||
}
|
||||
default: return Debug.fail("Unexpected private identifier placement");
|
||||
}
|
||||
}
|
||||
|
||||
function createPrivateIdentifierInstanceFieldAssignment(info: PrivateIdentifierInstanceField, receiver: Expression, right: Expression, operator: AssignmentOperator) {
|
||||
receiver = visitNode(receiver, visitor, isExpression);
|
||||
right = visitNode(right, visitor, isExpression);
|
||||
if (isCompoundAssignment(operator)) {
|
||||
const { readExpression, initializeExpression } = createCopiableReceiverExpr(receiver);
|
||||
return createClassPrivateFieldSetHelper(
|
||||
context,
|
||||
initializeExpression || readExpression,
|
||||
info.weakMapName,
|
||||
createBinary(
|
||||
createClassPrivateFieldGetHelper(context, readExpression, info.weakMapName),
|
||||
getNonAssignmentOperatorForCompoundAssignment(operator),
|
||||
right
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
return createClassPrivateFieldSetHelper(context, receiver, info.weakMapName, right);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the environment for a class.
|
||||
*/
|
||||
function visitClassLike(node: ClassLikeDeclaration) {
|
||||
const savedPendingExpressions = pendingExpressions;
|
||||
pendingExpressions = undefined;
|
||||
if (shouldTransformPrivateFields) {
|
||||
startPrivateIdentifierEnvironment();
|
||||
}
|
||||
|
||||
const result = isClassDeclaration(node) ?
|
||||
visitClassDeclaration(node) :
|
||||
visitClassExpression(node);
|
||||
|
||||
if (shouldTransformPrivateFields) {
|
||||
endPrivateIdentifierEnvironment();
|
||||
}
|
||||
pendingExpressions = savedPendingExpressions;
|
||||
return result;
|
||||
}
|
||||
|
||||
function doesClassElementNeedTransform(node: ClassElement) {
|
||||
return isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && isPrivateIdentifier(node.name));
|
||||
}
|
||||
|
||||
function visitClassDeclaration(node: ClassDeclaration) {
|
||||
if (!forEach(node.members, doesClassElementNeedTransform)) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
const extendsClauseElement = getEffectiveBaseTypeNode(node);
|
||||
const isDerivedClass = !!(extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== SyntaxKind.NullKeyword);
|
||||
@@ -167,8 +476,6 @@ namespace ts {
|
||||
statements.push(createExpressionStatement(inlineExpressions(pendingExpressions)));
|
||||
}
|
||||
|
||||
pendingExpressions = savedPendingExpressions;
|
||||
|
||||
// Emit static property assignment. Because classDeclaration is lexically evaluated,
|
||||
// it is safe to emit static property assignment after classDeclaration
|
||||
// From ES6 specification:
|
||||
@@ -183,11 +490,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitClassExpression(node: ClassExpression): Expression {
|
||||
if (!forEach(node.members, isPropertyDeclaration)) {
|
||||
if (!forEach(node.members, doesClassElementNeedTransform)) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
const savedPendingExpressions = pendingExpressions;
|
||||
pendingExpressions = undefined;
|
||||
|
||||
// If this class expression is a transformation of a decorated class declaration,
|
||||
// then we want to output the pendingExpressions as statements, not as inlined
|
||||
@@ -219,7 +524,6 @@ namespace ts {
|
||||
if (pendingStatements && pendingExpressions && some(pendingExpressions)) {
|
||||
pendingStatements.push(createExpressionStatement(inlineExpressions(pendingExpressions)));
|
||||
}
|
||||
pendingExpressions = savedPendingExpressions;
|
||||
|
||||
if (pendingStatements && some(staticProperties)) {
|
||||
addPropertyStatements(pendingStatements, staticProperties, getInternalName(node));
|
||||
@@ -247,16 +551,23 @@ namespace ts {
|
||||
addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
|
||||
expressions.push(startOnNewLine(temp));
|
||||
|
||||
pendingExpressions = savedPendingExpressions;
|
||||
return inlineExpressions(expressions);
|
||||
}
|
||||
}
|
||||
|
||||
pendingExpressions = savedPendingExpressions;
|
||||
return classExpression;
|
||||
}
|
||||
|
||||
function transformClassMembers(node: ClassDeclaration | ClassExpression, isDerivedClass: boolean) {
|
||||
if (shouldTransformPrivateFields) {
|
||||
// Declare private names.
|
||||
for (const member of node.members) {
|
||||
if (isPrivateIdentifierPropertyDeclaration(member)) {
|
||||
addPrivateIdentifierToEnvironment(member.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const members: ClassElement[] = [];
|
||||
const constructor = transformConstructor(node, isDerivedClass);
|
||||
if (constructor) {
|
||||
@@ -266,10 +577,22 @@ namespace ts {
|
||||
return setTextRange(createNodeArray(members), /*location*/ node.members);
|
||||
}
|
||||
|
||||
function isPropertyDeclarationThatRequiresConstructorStatement(member: ClassElement): member is PropertyDeclaration {
|
||||
if (!isPropertyDeclaration(member) || hasStaticModifier(member)) {
|
||||
return false;
|
||||
}
|
||||
if (context.getCompilerOptions().useDefineForClassFields) {
|
||||
// If we are using define semantics and targeting ESNext or higher,
|
||||
// then we don't need to transform any class properties.
|
||||
return languageVersion < ScriptTarget.ESNext;
|
||||
}
|
||||
return isInitializedProperty(member) || shouldTransformPrivateFields && isPrivateIdentifierPropertyDeclaration(member);
|
||||
}
|
||||
|
||||
function transformConstructor(node: ClassDeclaration | ClassExpression, isDerivedClass: boolean) {
|
||||
const constructor = visitNode(getFirstConstructorWithBody(node), visitor, isConstructorDeclaration);
|
||||
const containsProperty = forEach(node.members, m => isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields));
|
||||
if (!containsProperty) {
|
||||
const properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement);
|
||||
if (!some(properties)) {
|
||||
return constructor;
|
||||
}
|
||||
const parameters = visitParameterList(constructor ? constructor.parameters : undefined, visitor, context);
|
||||
@@ -295,7 +618,11 @@ namespace ts {
|
||||
|
||||
function transformConstructorBody(node: ClassDeclaration | ClassExpression, constructor: ConstructorDeclaration | undefined, isDerivedClass: boolean) {
|
||||
const useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
|
||||
const properties = getProperties(node, /*requireInitializer*/ !useDefineForClassFields, /*isStatic*/ false);
|
||||
let properties = getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false);
|
||||
if (!useDefineForClassFields) {
|
||||
properties = filter(properties, property => !!property.initializer || isPrivateIdentifier(property.name));
|
||||
}
|
||||
|
||||
|
||||
// Only generate synthetic constructor when there are property initializers to move.
|
||||
if (!constructor && !some(properties)) {
|
||||
@@ -377,7 +704,11 @@ namespace ts {
|
||||
*/
|
||||
function addPropertyStatements(statements: Statement[], properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) {
|
||||
for (const property of properties) {
|
||||
const statement = createExpressionStatement(transformInitializedProperty(property, receiver));
|
||||
const expression = transformProperty(property, receiver);
|
||||
if (!expression) {
|
||||
continue;
|
||||
}
|
||||
const statement = createExpressionStatement(expression);
|
||||
setSourceMapRange(statement, moveRangePastModifiers(property));
|
||||
setCommentRange(statement, property);
|
||||
setOriginalNode(statement, property);
|
||||
@@ -394,7 +725,10 @@ namespace ts {
|
||||
function generateInitializedPropertyExpressions(properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) {
|
||||
const expressions: Expression[] = [];
|
||||
for (const property of properties) {
|
||||
const expression = transformInitializedProperty(property, receiver);
|
||||
const expression = transformProperty(property, receiver);
|
||||
if (!expression) {
|
||||
continue;
|
||||
}
|
||||
startOnNewLine(expression);
|
||||
setSourceMapRange(expression, moveRangePastModifiers(property));
|
||||
setCommentRange(expression, property);
|
||||
@@ -411,17 +745,43 @@ namespace ts {
|
||||
* @param property The property declaration.
|
||||
* @param receiver The object receiving the property assignment.
|
||||
*/
|
||||
function transformInitializedProperty(property: PropertyDeclaration, receiver: LeftHandSideExpression) {
|
||||
function transformProperty(property: PropertyDeclaration, receiver: LeftHandSideExpression) {
|
||||
// We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name)
|
||||
const emitAssignment = !context.getCompilerOptions().useDefineForClassFields;
|
||||
const propertyName = isComputedPropertyName(property.name) && !isSimpleInlineableExpression(property.name.expression)
|
||||
? updateComputedPropertyName(property.name, getGeneratedNameForNode(property.name))
|
||||
: property.name;
|
||||
|
||||
if (shouldTransformPrivateFields && isPrivateIdentifier(propertyName)) {
|
||||
const privateIdentifierInfo = accessPrivateIdentifier(propertyName);
|
||||
if (privateIdentifierInfo) {
|
||||
switch (privateIdentifierInfo.placement) {
|
||||
case PrivateIdentifierPlacement.InstanceField: {
|
||||
return createPrivateInstanceFieldInitializer(
|
||||
receiver,
|
||||
visitNode(property.initializer, visitor, isExpression),
|
||||
privateIdentifierInfo.weakMapName
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Debug.fail("Undeclared private name for property declaration.");
|
||||
}
|
||||
}
|
||||
if (isPrivateIdentifier(propertyName) && !property.initializer) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (isPrivateIdentifier(propertyName) && !property.initializer) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const initializer = property.initializer || emitAssignment ? visitNode(property.initializer, visitor, isExpression)
|
||||
: hasModifier(getOriginalNode(property), ModifierFlags.ParameterPropertyModifier) && isIdentifier(propertyName) ? propertyName
|
||||
: createVoidZero();
|
||||
if (emitAssignment) {
|
||||
|
||||
if (emitAssignment || isPrivateIdentifier(propertyName)) {
|
||||
const memberAccess = createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
|
||||
return createAssignment(memberAccess, initializer);
|
||||
}
|
||||
@@ -517,6 +877,218 @@ namespace ts {
|
||||
return (inlinable || isIdentifier(innerExpression)) ? undefined : expression;
|
||||
}
|
||||
}
|
||||
|
||||
function startPrivateIdentifierEnvironment() {
|
||||
privateIdentifierEnvironmentStack.push(currentPrivateIdentifierEnvironment);
|
||||
currentPrivateIdentifierEnvironment = undefined;
|
||||
}
|
||||
|
||||
function endPrivateIdentifierEnvironment() {
|
||||
currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop();
|
||||
}
|
||||
|
||||
function addPrivateIdentifierToEnvironment(name: PrivateIdentifier) {
|
||||
const text = getTextOfPropertyName(name) as string;
|
||||
const weakMapName = createOptimisticUniqueName("_" + text.substring(1));
|
||||
weakMapName.autoGenerateFlags |= GeneratedIdentifierFlags.ReservedInNestedScopes;
|
||||
hoistVariableDeclaration(weakMapName);
|
||||
(currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = createUnderscoreEscapedMap()))
|
||||
.set(name.escapedText, { placement: PrivateIdentifierPlacement.InstanceField, weakMapName });
|
||||
(pendingExpressions || (pendingExpressions = [])).push(
|
||||
createAssignment(
|
||||
weakMapName,
|
||||
createNew(
|
||||
createIdentifier("WeakMap"),
|
||||
/*typeArguments*/ undefined,
|
||||
[]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function accessPrivateIdentifier(name: PrivateIdentifier) {
|
||||
if (currentPrivateIdentifierEnvironment) {
|
||||
const info = currentPrivateIdentifierEnvironment.get(name.escapedText);
|
||||
if (info) {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
for (let i = privateIdentifierEnvironmentStack.length - 1; i >= 0; --i) {
|
||||
const env = privateIdentifierEnvironmentStack[i];
|
||||
if (!env) {
|
||||
continue;
|
||||
}
|
||||
const info = env.get(name.escapedText);
|
||||
if (info) {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
function wrapPrivateIdentifierForDestructuringTarget(node: PrivateIdentifierPropertyAccessExpression) {
|
||||
const parameter = getGeneratedNameForNode(node);
|
||||
const info = accessPrivateIdentifier(node.name);
|
||||
if (!info) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
let receiver = node.expression;
|
||||
// We cannot copy `this` or `super` into the function because they will be bound
|
||||
// differently inside the function.
|
||||
if (isThisProperty(node) || isSuperProperty(node) || !isSimpleCopiableExpression(node.expression)) {
|
||||
receiver = createTempVariable(hoistVariableDeclaration);
|
||||
(receiver as Identifier).autoGenerateFlags! |= GeneratedIdentifierFlags.ReservedInNestedScopes;
|
||||
(pendingExpressions || (pendingExpressions = [])).push(createBinary(receiver, SyntaxKind.EqualsToken, node.expression));
|
||||
}
|
||||
return createPropertyAccess(
|
||||
// Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560)
|
||||
createParen(
|
||||
createObjectLiteral([
|
||||
createSetAccessor(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
"value",
|
||||
[createParameter(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
parameter,
|
||||
/*questionToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
/*initializer*/ undefined
|
||||
)],
|
||||
createBlock(
|
||||
[createExpressionStatement(
|
||||
createPrivateIdentifierAssignment(
|
||||
info,
|
||||
receiver,
|
||||
parameter,
|
||||
SyntaxKind.EqualsToken
|
||||
)
|
||||
)]
|
||||
)
|
||||
)
|
||||
])
|
||||
),
|
||||
"value"
|
||||
);
|
||||
}
|
||||
|
||||
function visitArrayAssignmentTarget(node: AssignmentPattern) {
|
||||
const target = getTargetOfBindingOrAssignmentElement(node);
|
||||
if (target && isPrivateIdentifierPropertyAccessExpression(target)) {
|
||||
const wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
|
||||
if (isAssignmentExpression(node)) {
|
||||
return updateBinary(
|
||||
node,
|
||||
wrapped,
|
||||
visitNode(node.right, visitor, isExpression),
|
||||
node.operatorToken
|
||||
);
|
||||
}
|
||||
else if (isSpreadElement(node)) {
|
||||
return updateSpread(node, wrapped);
|
||||
}
|
||||
else {
|
||||
return wrapped;
|
||||
}
|
||||
}
|
||||
return visitNode(node, visitorDestructuringTarget);
|
||||
}
|
||||
|
||||
function visitObjectAssignmentTarget(node: ObjectLiteralElementLike) {
|
||||
if (isPropertyAssignment(node)) {
|
||||
const target = getTargetOfBindingOrAssignmentElement(node);
|
||||
if (target && isPrivateIdentifierPropertyAccessExpression(target)) {
|
||||
const initializer = getInitializerOfBindingOrAssignmentElement(node);
|
||||
const wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
|
||||
return updatePropertyAssignment(
|
||||
node,
|
||||
visitNode(node.name, visitor),
|
||||
initializer ? createAssignment(wrapped, visitNode(initializer, visitor)) : wrapped,
|
||||
);
|
||||
}
|
||||
return updatePropertyAssignment(
|
||||
node,
|
||||
visitNode(node.name, visitor),
|
||||
visitNode(node.initializer, visitorDestructuringTarget)
|
||||
);
|
||||
}
|
||||
return visitNode(node, visitor);
|
||||
}
|
||||
|
||||
|
||||
function visitAssignmentPattern(node: AssignmentPattern) {
|
||||
if (isArrayLiteralExpression(node)) {
|
||||
// Transforms private names in destructuring assignment array bindings.
|
||||
//
|
||||
// Source:
|
||||
// ([ this.#myProp ] = [ "hello" ]);
|
||||
//
|
||||
// Transformation:
|
||||
// [ { set value(x) { this.#myProp = x; } }.value ] = [ "hello" ];
|
||||
return updateArrayLiteral(
|
||||
node,
|
||||
visitNodes(node.elements, visitArrayAssignmentTarget, isExpression)
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Transforms private names in destructuring assignment object bindings.
|
||||
//
|
||||
// Source:
|
||||
// ({ stringProperty: this.#myProp } = { stringProperty: "hello" });
|
||||
//
|
||||
// Transformation:
|
||||
// ({ stringProperty: { set value(x) { this.#myProp = x; } }.value }) = { stringProperty: "hello" };
|
||||
return updateObjectLiteral(
|
||||
node,
|
||||
visitNodes(node.properties, visitObjectAssignmentTarget, isObjectLiteralElementLike)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createPrivateInstanceFieldInitializer(receiver: LeftHandSideExpression, initializer: Expression | undefined, weakMapName: Identifier) {
|
||||
return createCall(
|
||||
createPropertyAccess(weakMapName, "set"),
|
||||
/*typeArguments*/ undefined,
|
||||
[receiver, initializer || createVoidZero()]
|
||||
);
|
||||
}
|
||||
|
||||
export const classPrivateFieldGetHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:classPrivateFieldGet",
|
||||
scoped: false,
|
||||
text: `
|
||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to get private field on non-instance");
|
||||
}
|
||||
return privateMap.get(receiver);
|
||||
};`
|
||||
};
|
||||
|
||||
function createClassPrivateFieldGetHelper(context: TransformationContext, receiver: Expression, privateField: Identifier) {
|
||||
context.requestEmitHelper(classPrivateFieldGetHelper);
|
||||
return createCall(getUnscopedHelperName("__classPrivateFieldGet"), /* typeArguments */ undefined, [receiver, privateField]);
|
||||
}
|
||||
|
||||
export const classPrivateFieldSetHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:classPrivateFieldSet",
|
||||
scoped: false,
|
||||
text: `
|
||||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to set private field on non-instance");
|
||||
}
|
||||
privateMap.set(receiver, value);
|
||||
return value;
|
||||
};`
|
||||
};
|
||||
|
||||
function createClassPrivateFieldSetHelper(context: TransformationContext, receiver: Expression, privateField: Identifier, value: Expression) {
|
||||
context.requestEmitHelper(classPrivateFieldSetHelper);
|
||||
return createCall(getUnscopedHelperName("__classPrivateFieldSet"), /* typeArguments */ undefined, [receiver, privateField, value]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -851,6 +851,9 @@ namespace ts {
|
||||
return cleanup(ctor);
|
||||
}
|
||||
case SyntaxKind.MethodDeclaration: {
|
||||
if (isPrivateIdentifier(input.name)) {
|
||||
return cleanup(/*returnValue*/ undefined);
|
||||
}
|
||||
const sig = createSignatureDeclaration(
|
||||
SyntaxKind.MethodSignature,
|
||||
ensureTypeParams(input, input.typeParameters),
|
||||
@@ -863,6 +866,9 @@ namespace ts {
|
||||
return cleanup(sig);
|
||||
}
|
||||
case SyntaxKind.GetAccessor: {
|
||||
if (isPrivateIdentifier(input.name)) {
|
||||
return cleanup(/*returnValue*/ undefined);
|
||||
}
|
||||
const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
|
||||
return cleanup(updateGetAccessor(
|
||||
input,
|
||||
@@ -874,6 +880,9 @@ namespace ts {
|
||||
/*body*/ undefined));
|
||||
}
|
||||
case SyntaxKind.SetAccessor: {
|
||||
if (isPrivateIdentifier(input.name)) {
|
||||
return cleanup(/*returnValue*/ undefined);
|
||||
}
|
||||
return cleanup(updateSetAccessor(
|
||||
input,
|
||||
/*decorators*/ undefined,
|
||||
@@ -883,6 +892,9 @@ namespace ts {
|
||||
/*body*/ undefined));
|
||||
}
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
if (isPrivateIdentifier(input.name)) {
|
||||
return cleanup(/*returnValue*/ undefined);
|
||||
}
|
||||
return cleanup(updateProperty(
|
||||
input,
|
||||
/*decorators*/ undefined,
|
||||
@@ -893,6 +905,9 @@ namespace ts {
|
||||
ensureNoInitializer(input)
|
||||
));
|
||||
case SyntaxKind.PropertySignature:
|
||||
if (isPrivateIdentifier(input.name)) {
|
||||
return cleanup(/*returnValue*/ undefined);
|
||||
}
|
||||
return cleanup(updatePropertySignature(
|
||||
input,
|
||||
ensureModifiers(input),
|
||||
@@ -902,6 +917,9 @@ namespace ts {
|
||||
ensureNoInitializer(input)
|
||||
));
|
||||
case SyntaxKind.MethodSignature: {
|
||||
if (isPrivateIdentifier(input.name)) {
|
||||
return cleanup(/*returnValue*/ undefined);
|
||||
}
|
||||
return cleanup(updateMethodSignature(
|
||||
input,
|
||||
ensureTypeParams(input, input.typeParameters),
|
||||
@@ -1283,7 +1301,20 @@ namespace ts {
|
||||
}));
|
||||
getSymbolAccessibilityDiagnostic = oldDiag;
|
||||
}
|
||||
const members = createNodeArray(concatenate(parameterProperties, visitNodes(input.members, visitDeclarationSubtree)));
|
||||
|
||||
const hasPrivateIdentifier = some(input.members, member => !!member.name && isPrivateIdentifier(member.name));
|
||||
const privateIdentifier = hasPrivateIdentifier ? [
|
||||
createProperty(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
createPrivateIdentifier("#private"),
|
||||
/*questionToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
/*initializer*/ undefined
|
||||
)
|
||||
] : undefined;
|
||||
const memberNodes = concatenate(concatenate(privateIdentifier, parameterProperties), visitNodes(input.members, visitDeclarationSubtree));
|
||||
const members = createNodeArray(memberNodes);
|
||||
|
||||
const extendsClause = getEffectiveBaseTypeNode(input);
|
||||
if (extendsClause && !isEntityNameExpression(extendsClause.expression) && extendsClause.expression.kind !== SyntaxKind.NullKeyword) {
|
||||
|
||||
@@ -1592,16 +1592,16 @@ namespace ts {
|
||||
const commentRange = getCommentRange(member);
|
||||
const sourceMapRange = getSourceMapRange(member);
|
||||
const memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container);
|
||||
const propertyName = visitNode(member.name, visitor, isPropertyName);
|
||||
let e: Expression;
|
||||
if (context.getCompilerOptions().useDefineForClassFields) {
|
||||
const propertyName = visitNode(member.name, visitor, isPropertyName);
|
||||
if (!isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) {
|
||||
const name = isComputedPropertyName(propertyName) ? propertyName.expression
|
||||
: isIdentifier(propertyName) ? createStringLiteral(unescapeLeadingUnderscores(propertyName.escapedText))
|
||||
: propertyName;
|
||||
e = createObjectDefinePropertyCall(receiver, name, createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
|
||||
}
|
||||
else {
|
||||
const memberName = createMemberAccessForPropertyName(receiver, visitNode(member.name, visitor, isPropertyName), /*location*/ member.name);
|
||||
const memberName = createMemberAccessForPropertyName(receiver, propertyName, /*location*/ member.name);
|
||||
e = createAssignment(memberName, memberFunction);
|
||||
}
|
||||
setEmitFlags(memberFunction, EmitFlags.NoComments);
|
||||
@@ -1647,7 +1647,11 @@ namespace ts {
|
||||
setEmitFlags(target, EmitFlags.NoComments | EmitFlags.NoTrailingSourceMap);
|
||||
setSourceMapRange(target, firstAccessor.name);
|
||||
|
||||
const propertyName = createExpressionForPropertyName(visitNode(firstAccessor.name, visitor, isPropertyName));
|
||||
const visitedAccessorName = visitNode(firstAccessor.name, visitor, isPropertyName);
|
||||
if (isPrivateIdentifier(visitedAccessorName)) {
|
||||
return Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015.");
|
||||
}
|
||||
const propertyName = createExpressionForPropertyName(visitedAccessorName);
|
||||
setEmitFlags(propertyName, EmitFlags.NoComments | EmitFlags.NoLeadingSourceMap);
|
||||
setSourceMapRange(propertyName, firstAccessor.name);
|
||||
|
||||
|
||||
@@ -82,6 +82,9 @@ namespace ts {
|
||||
* @param node A PropertyAccessExpression
|
||||
*/
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression): Expression {
|
||||
if (isPrivateIdentifier(node.name)) {
|
||||
return node;
|
||||
}
|
||||
const literalName = trySubstituteReservedName(node.name);
|
||||
if (literalName) {
|
||||
return setTextRange(createElementAccess(node.expression, literalName), node);
|
||||
|
||||
@@ -667,28 +667,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isCompoundAssignment(kind: BinaryOperator): kind is CompoundAssignmentOperator {
|
||||
return kind >= SyntaxKind.FirstCompoundAssignment
|
||||
&& kind <= SyntaxKind.LastCompoundAssignment;
|
||||
}
|
||||
|
||||
function getOperatorForCompoundAssignment(kind: CompoundAssignmentOperator): BitwiseOperatorOrHigher {
|
||||
switch (kind) {
|
||||
case SyntaxKind.PlusEqualsToken: return SyntaxKind.PlusToken;
|
||||
case SyntaxKind.MinusEqualsToken: return SyntaxKind.MinusToken;
|
||||
case SyntaxKind.AsteriskEqualsToken: return SyntaxKind.AsteriskToken;
|
||||
case SyntaxKind.AsteriskAsteriskEqualsToken: return SyntaxKind.AsteriskAsteriskToken;
|
||||
case SyntaxKind.SlashEqualsToken: return SyntaxKind.SlashToken;
|
||||
case SyntaxKind.PercentEqualsToken: return SyntaxKind.PercentToken;
|
||||
case SyntaxKind.LessThanLessThanEqualsToken: return SyntaxKind.LessThanLessThanToken;
|
||||
case SyntaxKind.GreaterThanGreaterThanEqualsToken: return SyntaxKind.GreaterThanGreaterThanToken;
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken: return SyntaxKind.GreaterThanGreaterThanGreaterThanToken;
|
||||
case SyntaxKind.AmpersandEqualsToken: return SyntaxKind.AmpersandToken;
|
||||
case SyntaxKind.BarEqualsToken: return SyntaxKind.BarToken;
|
||||
case SyntaxKind.CaretEqualsToken: return SyntaxKind.CaretToken;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a right-associative binary expression containing `yield`.
|
||||
*
|
||||
@@ -748,7 +726,7 @@ namespace ts {
|
||||
setTextRange(
|
||||
createBinary(
|
||||
cacheExpression(target),
|
||||
getOperatorForCompoundAssignment(operator),
|
||||
getNonAssignmentOperatorForCompoundAssignment(operator),
|
||||
visitNode(right, visitor, isExpression)
|
||||
),
|
||||
node
|
||||
|
||||
@@ -1784,14 +1784,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an expression that represents a property name. For a computed property, a
|
||||
* name is generated for the node.
|
||||
* Gets an expression that represents a property name (for decorated properties or enums).
|
||||
* For a computed property, a name is generated for the node.
|
||||
*
|
||||
* @param member The member whose name should be converted into an expression.
|
||||
*/
|
||||
function getExpressionForPropertyName(member: ClassElement | EnumMember, generateNameForComputedPropertyName: boolean): Expression {
|
||||
const name = member.name!;
|
||||
if (isComputedPropertyName(name)) {
|
||||
if (isPrivateIdentifier(name)) {
|
||||
return createIdentifier("");
|
||||
}
|
||||
else if (isComputedPropertyName(name)) {
|
||||
return generateNameForComputedPropertyName && !isSimpleInlineableExpression(name.expression)
|
||||
? getGeneratedNameForNode(name)
|
||||
: name.expression;
|
||||
|
||||
@@ -254,6 +254,28 @@ namespace ts {
|
||||
isWellKnownSymbolSyntactically(expression);
|
||||
}
|
||||
|
||||
export function isCompoundAssignment(kind: BinaryOperator): kind is CompoundAssignmentOperator {
|
||||
return kind >= SyntaxKind.FirstCompoundAssignment
|
||||
&& kind <= SyntaxKind.LastCompoundAssignment;
|
||||
}
|
||||
|
||||
export function getNonAssignmentOperatorForCompoundAssignment(kind: CompoundAssignmentOperator): BitwiseOperatorOrHigher {
|
||||
switch (kind) {
|
||||
case SyntaxKind.PlusEqualsToken: return SyntaxKind.PlusToken;
|
||||
case SyntaxKind.MinusEqualsToken: return SyntaxKind.MinusToken;
|
||||
case SyntaxKind.AsteriskEqualsToken: return SyntaxKind.AsteriskToken;
|
||||
case SyntaxKind.AsteriskAsteriskEqualsToken: return SyntaxKind.AsteriskAsteriskToken;
|
||||
case SyntaxKind.SlashEqualsToken: return SyntaxKind.SlashToken;
|
||||
case SyntaxKind.PercentEqualsToken: return SyntaxKind.PercentToken;
|
||||
case SyntaxKind.LessThanLessThanEqualsToken: return SyntaxKind.LessThanLessThanToken;
|
||||
case SyntaxKind.GreaterThanGreaterThanEqualsToken: return SyntaxKind.GreaterThanGreaterThanToken;
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken: return SyntaxKind.GreaterThanGreaterThanGreaterThanToken;
|
||||
case SyntaxKind.AmpersandEqualsToken: return SyntaxKind.AmpersandToken;
|
||||
case SyntaxKind.BarEqualsToken: return SyntaxKind.BarToken;
|
||||
case SyntaxKind.CaretEqualsToken: return SyntaxKind.CaretToken;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds super call and preceding prologue directives into the list of statements.
|
||||
*
|
||||
@@ -323,8 +345,14 @@ namespace ts {
|
||||
&& hasStaticModifier(member) === isStatic;
|
||||
}
|
||||
|
||||
export function isInitializedProperty(member: ClassElement, requireInitializer: boolean): member is PropertyDeclaration {
|
||||
return isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer);
|
||||
/**
|
||||
* Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer.
|
||||
*
|
||||
* @param member The class element node.
|
||||
* @param isStatic A value indicating whether the member should be a static or instance member.
|
||||
*/
|
||||
export function isInitializedProperty(member: ClassElement): member is PropertyDeclaration & { initializer: Expression; } {
|
||||
return member.kind === SyntaxKind.PropertyDeclaration
|
||||
&& (<PropertyDeclaration>member).initializer !== undefined;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+31
-4
@@ -201,8 +201,9 @@ namespace ts {
|
||||
AmpersandEqualsToken,
|
||||
BarEqualsToken,
|
||||
CaretEqualsToken,
|
||||
// Identifiers
|
||||
// Identifiers and PrivateIdentifiers
|
||||
Identifier,
|
||||
PrivateIdentifier,
|
||||
// Reserved words
|
||||
BreakKeyword,
|
||||
CaseKeyword,
|
||||
@@ -831,10 +832,11 @@ namespace ts {
|
||||
|
||||
export type EntityName = Identifier | QualifiedName;
|
||||
|
||||
export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName;
|
||||
export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier;
|
||||
|
||||
export type DeclarationName =
|
||||
| Identifier
|
||||
| PrivateIdentifier
|
||||
| StringLiteralLike
|
||||
| NumericLiteral
|
||||
| ComputedPropertyName
|
||||
@@ -886,6 +888,14 @@ namespace ts {
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface PrivateIdentifier extends Node {
|
||||
kind: SyntaxKind.PrivateIdentifier;
|
||||
// escaping not strictly necessary
|
||||
// avoids gotchas in transforms and utils
|
||||
escapedText: __String;
|
||||
}
|
||||
|
||||
|
||||
/* @internal */
|
||||
// A name that supports late-binding (used in checker)
|
||||
export interface LateBoundName extends ComputedPropertyName {
|
||||
@@ -999,6 +1009,11 @@ namespace ts {
|
||||
initializer?: Expression; // Optional initializer
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export interface PrivateIdentifierPropertyDeclaration extends PropertyDeclaration {
|
||||
name: PrivateIdentifier;
|
||||
}
|
||||
|
||||
export interface ObjectLiteralElement extends NamedDeclaration {
|
||||
_objectLiteralBrand: any;
|
||||
name?: PropertyName;
|
||||
@@ -1831,11 +1846,17 @@ namespace ts {
|
||||
kind: SyntaxKind.PropertyAccessExpression;
|
||||
expression: LeftHandSideExpression;
|
||||
questionDotToken?: QuestionDotToken;
|
||||
name: Identifier;
|
||||
name: Identifier | PrivateIdentifier;
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export interface PrivateIdentifierPropertyAccessExpression extends PropertyAccessExpression {
|
||||
name: PrivateIdentifier;
|
||||
}
|
||||
|
||||
export interface PropertyAccessChain extends PropertyAccessExpression {
|
||||
_optionalChainBrand: any;
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -1851,6 +1872,7 @@ namespace ts {
|
||||
export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression {
|
||||
_propertyAccessExpressionLikeQualifiedNameBrand?: any;
|
||||
expression: EntityNameExpression;
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
export interface ElementAccessExpression extends MemberExpression {
|
||||
@@ -1909,6 +1931,7 @@ namespace ts {
|
||||
/** @internal */
|
||||
export interface WellKnownSymbolExpression extends PropertyAccessExpression {
|
||||
expression: Identifier & { escapedText: "Symbol" };
|
||||
name: Identifier;
|
||||
}
|
||||
/** @internal */
|
||||
export type BindableObjectDefinePropertyCall = CallExpression & { arguments: { 0: BindableStaticNameExpression, 1: StringLiteralLike | NumericLiteral, 2: ObjectLiteralExpression } };
|
||||
@@ -3334,6 +3357,7 @@ namespace ts {
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
|
||||
getPrivateIdentifierPropertyOfType(leftType: Type, name: string, location: Node): Symbol | undefined;
|
||||
/* @internal */ getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined;
|
||||
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined;
|
||||
getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[];
|
||||
@@ -4182,6 +4206,7 @@ namespace ts {
|
||||
AssignmentsMarked = 0x00800000, // Parameter assignments have been marked
|
||||
ClassWithConstructorReference = 0x01000000, // Class that contains a binding to its constructor inside of the class body.
|
||||
ConstructorReferenceInClass = 0x02000000, // Binding to a class constructor inside of the class's body.
|
||||
ContainsClassWithPrivateIdentifiers = 0x04000000, // Marked on all block-scoped containers containing a class with private identifiers.
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -5766,8 +5791,10 @@ namespace ts {
|
||||
AsyncValues = 1 << 15, // __asyncValues (used by ES2017 for..await..of transformation)
|
||||
ExportStar = 1 << 16, // __exportStar (used by CommonJS/AMD/UMD module transformation)
|
||||
MakeTemplateObject = 1 << 17, // __makeTemplateObject (used for constructing template string array objects)
|
||||
ClassPrivateFieldGet = 1 << 18, // __classPrivateFieldGet (used by the class private field transformation)
|
||||
ClassPrivateFieldSet = 1 << 19, // __classPrivateFieldSet (used by the class private field transformation)
|
||||
FirstEmitHelper = Extends,
|
||||
LastEmitHelper = MakeTemplateObject,
|
||||
LastEmitHelper = ClassPrivateFieldSet,
|
||||
|
||||
// Helpers included by ES2015 for..of
|
||||
ForOfIncludes = Values,
|
||||
|
||||
@@ -840,6 +840,7 @@ namespace ts {
|
||||
export function getTextOfPropertyName(name: PropertyName | NoSubstitutionTemplateLiteral): __String {
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.PrivateIdentifier:
|
||||
return name.escapedText;
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
@@ -860,9 +861,14 @@ namespace ts {
|
||||
case SyntaxKind.QualifiedName:
|
||||
return entityNameToString(name.left) + "." + entityNameToString(name.right);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return entityNameToString(name.expression) + "." + entityNameToString(name.name);
|
||||
if (isIdentifier(name.name)) {
|
||||
return entityNameToString(name.expression) + "." + entityNameToString(name.name);
|
||||
}
|
||||
else {
|
||||
return Debug.assertNever(name.name);
|
||||
}
|
||||
default:
|
||||
throw Debug.assertNever(name);
|
||||
return Debug.assertNever(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1578,6 +1584,10 @@ namespace ts {
|
||||
export function nodeCanBeDecorated(node: ClassElement, parent: Node): boolean;
|
||||
export function nodeCanBeDecorated(node: Node, parent: Node, grandparent: Node): boolean;
|
||||
export function nodeCanBeDecorated(node: Node, parent?: Node, grandparent?: Node): boolean {
|
||||
// private names cannot be used with decorators yet
|
||||
if (isNamedDeclaration(node) && isPrivateIdentifier(node.name)) {
|
||||
return false;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
// classes are valid targets
|
||||
@@ -1995,13 +2005,18 @@ namespace ts {
|
||||
if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
|
||||
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name);
|
||||
}
|
||||
if (isIdentifier(name) && (isLiteralLikeAccess(initializer))) {
|
||||
return (initializer.expression.kind === SyntaxKind.ThisKeyword ||
|
||||
if (isIdentifier(name) && isLiteralLikeAccess(initializer) &&
|
||||
(initializer.expression.kind === SyntaxKind.ThisKeyword ||
|
||||
isIdentifier(initializer.expression) &&
|
||||
(initializer.expression.escapedText === "window" ||
|
||||
initializer.expression.escapedText === "self" ||
|
||||
initializer.expression.escapedText === "global")) &&
|
||||
isSameEntityName(name, getNameOrArgument(initializer));
|
||||
initializer.expression.escapedText === "global"))) {
|
||||
|
||||
const nameOrArgument = getNameOrArgument(initializer);
|
||||
if (isPrivateIdentifier(nameOrArgument)) {
|
||||
Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
|
||||
}
|
||||
return isSameEntityName(name, nameOrArgument);
|
||||
}
|
||||
if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
|
||||
return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
|
||||
@@ -2111,7 +2126,7 @@ namespace ts {
|
||||
* throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand)
|
||||
*/
|
||||
/* @internal */
|
||||
export function getElementOrPropertyAccessArgumentExpressionOrName(node: AccessExpression): Identifier | StringLiteralLike | NumericLiteral | ElementAccessExpression | undefined {
|
||||
export function getElementOrPropertyAccessArgumentExpressionOrName(node: AccessExpression): Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ElementAccessExpression | undefined {
|
||||
if (isPropertyAccessExpression(node)) {
|
||||
return node.name;
|
||||
}
|
||||
@@ -2913,6 +2928,7 @@ namespace ts {
|
||||
export function getPropertyNameForPropertyNameNode(name: PropertyName): __String | undefined {
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.PrivateIdentifier:
|
||||
return name.escapedText;
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
@@ -2944,17 +2960,25 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
export function getTextOfIdentifierOrLiteral(node: PropertyNameLiteral): string {
|
||||
return node.kind === SyntaxKind.Identifier ? idText(node) : node.text;
|
||||
return isIdentifierOrPrivateIdentifier(node) ? idText(node) : node.text;
|
||||
}
|
||||
|
||||
export function getEscapedTextOfIdentifierOrLiteral(node: PropertyNameLiteral): __String {
|
||||
return node.kind === SyntaxKind.Identifier ? node.escapedText : escapeLeadingUnderscores(node.text);
|
||||
return isIdentifierOrPrivateIdentifier(node) ? node.escapedText : escapeLeadingUnderscores(node.text);
|
||||
}
|
||||
|
||||
export function getPropertyNameForUniqueESSymbol(symbol: Symbol): __String {
|
||||
return `__@${getSymbolId(symbol)}@${symbol.escapedName}` as __String;
|
||||
}
|
||||
|
||||
export function getPropertyNameForKnownSymbolName(symbolName: string): __String {
|
||||
return "__@" + symbolName as __String;
|
||||
}
|
||||
|
||||
export function getSymbolNameForPrivateIdentifier(containingClassSymbol: Symbol, description: __String): __String {
|
||||
return `__#${getSymbolId(containingClassSymbol)}@${description}` as __String;
|
||||
}
|
||||
|
||||
export function isKnownSymbol(symbol: Symbol): boolean {
|
||||
return startsWith(symbol.escapedName as string, "__@");
|
||||
}
|
||||
@@ -4913,6 +4937,7 @@ namespace ts {
|
||||
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
getTokenConstructor(): new <TKind extends SyntaxKind>(kind: TKind, pos?: number, end?: number) => Token<TKind>;
|
||||
getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos?: number, end?: number) => Identifier;
|
||||
getPrivateIdentifierConstructor(): new (kind: SyntaxKind.PrivateIdentifier, pos?: number, end?: number) => PrivateIdentifier;
|
||||
getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos?: number, end?: number) => SourceFile;
|
||||
getSymbolConstructor(): new (flags: SymbolFlags, name: __String) => Symbol;
|
||||
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
|
||||
@@ -4967,6 +4992,7 @@ namespace ts {
|
||||
getNodeConstructor: () => <any>Node,
|
||||
getTokenConstructor: () => <any>Node,
|
||||
getIdentifierConstructor: () => <any>Node,
|
||||
getPrivateIdentifierConstructor: () => <any>Node,
|
||||
getSourceFileConstructor: () => <any>Node,
|
||||
getSymbolConstructor: () => <any>Symbol,
|
||||
getTypeConstructor: () => <any>Type,
|
||||
|
||||
@@ -453,10 +453,13 @@ namespace ts {
|
||||
return id.length >= 3 && id.charCodeAt(0) === CharacterCodes._ && id.charCodeAt(1) === CharacterCodes._ && id.charCodeAt(2) === CharacterCodes._ ? id.substr(1) : id;
|
||||
}
|
||||
|
||||
export function idText(identifier: Identifier): string {
|
||||
return unescapeLeadingUnderscores(identifier.escapedText);
|
||||
export function idText(identifierOrPrivateName: Identifier | PrivateIdentifier): string {
|
||||
return unescapeLeadingUnderscores(identifierOrPrivateName.escapedText);
|
||||
}
|
||||
export function symbolName(symbol: Symbol): string {
|
||||
if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
|
||||
return idText(symbol.valueDeclaration.name);
|
||||
}
|
||||
return unescapeLeadingUnderscores(symbol.escapedName);
|
||||
}
|
||||
|
||||
@@ -465,7 +468,7 @@ namespace ts {
|
||||
* attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol
|
||||
* will be merged with)
|
||||
*/
|
||||
function nameForNamelessJSDocTypedef(declaration: JSDocTypedefTag | JSDocEnumTag): Identifier | undefined {
|
||||
function nameForNamelessJSDocTypedef(declaration: JSDocTypedefTag | JSDocEnumTag): Identifier | PrivateIdentifier | undefined {
|
||||
const hostNode = declaration.parent.parent;
|
||||
if (!hostNode) {
|
||||
return undefined;
|
||||
@@ -524,7 +527,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined {
|
||||
export function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined {
|
||||
return declaration.name || nameForNamelessJSDocTypedef(declaration);
|
||||
}
|
||||
|
||||
@@ -878,6 +881,14 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.ComputedPropertyName;
|
||||
}
|
||||
|
||||
export function isPrivateIdentifier(node: Node): node is PrivateIdentifier {
|
||||
return node.kind === SyntaxKind.PrivateIdentifier;
|
||||
}
|
||||
|
||||
export function isIdentifierOrPrivateIdentifier(node: Node): node is Identifier | PrivateIdentifier {
|
||||
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PrivateIdentifier;
|
||||
}
|
||||
|
||||
// Signature elements
|
||||
|
||||
export function isTypeParameterDeclaration(node: Node): node is TypeParameterDeclaration {
|
||||
@@ -1721,6 +1732,17 @@ namespace ts {
|
||||
return isIdentifier(node) && (node.autoGenerateFlags! & GeneratedIdentifierFlags.KindMask) > GeneratedIdentifierFlags.None;
|
||||
}
|
||||
|
||||
// Private Identifiers
|
||||
/*@internal*/
|
||||
export function isPrivateIdentifierPropertyDeclaration(node: Node): node is PrivateIdentifierPropertyDeclaration {
|
||||
return isPropertyDeclaration(node) && isPrivateIdentifier(node.name);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function isPrivateIdentifierPropertyAccessExpression(node: Node): node is PrivateIdentifierPropertyAccessExpression {
|
||||
return isPropertyAccessExpression(node) && isPrivateIdentifier(node.name);
|
||||
}
|
||||
|
||||
// Keywords
|
||||
|
||||
/* @internal */
|
||||
|
||||
@@ -614,4 +614,4 @@ namespace ts {
|
||||
function aggregateTransformFlagsForChildNodes(transformFlags: TransformFlags, nodes: NodeArray<Node>): TransformFlags {
|
||||
return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ namespace ts {
|
||||
}
|
||||
return updatePropertyAccess(<PropertyAccessExpression>node,
|
||||
visitNode((<PropertyAccessExpression>node).expression, visitor, isExpression),
|
||||
visitNode((<PropertyAccessExpression>node).name, visitor, isIdentifier));
|
||||
visitNode((<PropertyAccessExpression>node).name, visitor, isIdentifierOrPrivateIdentifier));
|
||||
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
if (node.flags & NodeFlags.OptionalChain) {
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace ts.codefix {
|
||||
forEachExportReference(sourceFile, node => {
|
||||
const { text, originalKeywordKind } = node.name;
|
||||
if (!res.has(text) && (originalKeywordKind !== undefined && isNonContextualKeyword(originalKeywordKind)
|
||||
|| checker.resolveName(node.name.text, node, SymbolFlags.Value, /*excludeGlobals*/ true))) {
|
||||
|| checker.resolveName(text, node, SymbolFlags.Value, /*excludeGlobals*/ true))) {
|
||||
// Unconditionally add an underscore in case `text` is a keyword.
|
||||
res.set(text, makeUniqueName(`_${text}`, identifiers));
|
||||
}
|
||||
@@ -85,11 +85,11 @@ namespace ts.codefix {
|
||||
});
|
||||
}
|
||||
|
||||
function forEachExportReference(sourceFile: SourceFile, cb: (node: PropertyAccessExpression, isAssignmentLhs: boolean) => void): void {
|
||||
function forEachExportReference(sourceFile: SourceFile, cb: (node: (PropertyAccessExpression & { name: Identifier }), isAssignmentLhs: boolean) => void): void {
|
||||
sourceFile.forEachChild(function recur(node) {
|
||||
if (isPropertyAccessExpression(node) && isExportsOrModuleExportsOrAlias(sourceFile, node.expression)) {
|
||||
if (isPropertyAccessExpression(node) && isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && isIdentifier(node.name)) {
|
||||
const { parent } = node;
|
||||
cb(node, isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === SyntaxKind.EqualsToken);
|
||||
cb(node as typeof node & { name: Identifier }, isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === SyntaxKind.EqualsToken);
|
||||
}
|
||||
node.forEachChild(recur);
|
||||
});
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace ts.codefix {
|
||||
const { parentDeclaration, declSourceFile, inJs, makeStatic, token, call } = info;
|
||||
|
||||
// Always prefer to add a method declaration if possible.
|
||||
if (call) {
|
||||
if (call && !isPrivateIdentifier(token)) {
|
||||
addMethodDeclaration(context, changes, declSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences);
|
||||
}
|
||||
else {
|
||||
@@ -104,7 +104,7 @@ namespace ts.codefix {
|
||||
}
|
||||
interface ClassOrInterfaceInfo {
|
||||
readonly kind: InfoKind.ClassOrInterface;
|
||||
readonly token: Identifier;
|
||||
readonly token: Identifier | PrivateIdentifier;
|
||||
readonly parentDeclaration: ClassOrInterface;
|
||||
readonly makeStatic: boolean;
|
||||
readonly declSourceFile: SourceFile;
|
||||
@@ -118,7 +118,7 @@ namespace ts.codefix {
|
||||
// this.missing = 1;
|
||||
// ^^^^^^^
|
||||
const token = getTokenAtPosition(tokenSourceFile, tokenPos);
|
||||
if (!isIdentifier(token)) {
|
||||
if (!isIdentifier(token) && !isPrivateIdentifier(token)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -129,17 +129,25 @@ namespace ts.codefix {
|
||||
const { symbol } = leftExpressionType;
|
||||
if (!symbol || !symbol.declarations) return undefined;
|
||||
|
||||
const isClass = find(symbol.declarations, isClassLike);
|
||||
// Don't suggest adding private identifiers to anything other than a class.
|
||||
if (!isClass && isPrivateIdentifier(token)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Prefer to change the class instead of the interface if they are merged
|
||||
const classOrInterface = find(symbol.declarations, isClassLike) || find(symbol.declarations, isInterfaceDeclaration);
|
||||
const classOrInterface = isClass || find(symbol.declarations, isInterfaceDeclaration);
|
||||
if (classOrInterface && !program.isSourceFileFromExternalLibrary(classOrInterface.getSourceFile())) {
|
||||
const makeStatic = ((leftExpressionType as TypeReference).target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
||||
// Static private identifier properties are not supported yet.
|
||||
if (makeStatic && isPrivateIdentifier(token)) { return undefined; }
|
||||
const declSourceFile = classOrInterface.getSourceFile();
|
||||
const inJs = isSourceFileJS(declSourceFile);
|
||||
const call = tryCast(parent.parent, isCallExpression);
|
||||
return { kind: InfoKind.ClassOrInterface, token, parentDeclaration: classOrInterface, makeStatic, declSourceFile, inJs, call };
|
||||
}
|
||||
const enumDeclaration = find(symbol.declarations, isEnumDeclaration);
|
||||
if (enumDeclaration && !program.isSourceFileFromExternalLibrary(enumDeclaration.getSourceFile())) {
|
||||
if (enumDeclaration && !isPrivateIdentifier(token) && !program.isSourceFileFromExternalLibrary(enumDeclaration.getSourceFile())) {
|
||||
return { kind: InfoKind.Enum, token, parentDeclaration: enumDeclaration };
|
||||
}
|
||||
return undefined;
|
||||
@@ -174,10 +182,10 @@ namespace ts.codefix {
|
||||
return createStatement(createAssignment(createPropertyAccess(obj, propertyName), createIdentifier("undefined")));
|
||||
}
|
||||
|
||||
function getActionsForAddMissingMemberInTypeScriptFile(context: CodeFixContext, declSourceFile: SourceFile, classDeclaration: ClassOrInterface, token: Identifier, makeStatic: boolean): CodeFixAction[] | undefined {
|
||||
function getActionsForAddMissingMemberInTypeScriptFile(context: CodeFixContext, declSourceFile: SourceFile, classDeclaration: ClassOrInterface, token: Identifier | PrivateIdentifier, makeStatic: boolean): CodeFixAction[] | undefined {
|
||||
const typeNode = getTypeNode(context.program.getTypeChecker(), classDeclaration, token);
|
||||
const addProp = createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, token.text, typeNode);
|
||||
return makeStatic ? [addProp] : [addProp, createAddIndexSignatureAction(context, declSourceFile, classDeclaration, token.text, typeNode)];
|
||||
return makeStatic || isPrivateIdentifier(token) ? [addProp] : [addProp, createAddIndexSignatureAction(context, declSourceFile, classDeclaration, token.text, typeNode)];
|
||||
}
|
||||
|
||||
function getTypeNode(checker: TypeChecker, classDeclaration: ClassOrInterface, token: Node) {
|
||||
@@ -254,12 +262,14 @@ namespace ts.codefix {
|
||||
context: CodeFixContext,
|
||||
declSourceFile: SourceFile,
|
||||
classDeclaration: ClassOrInterface,
|
||||
token: Identifier,
|
||||
token: Identifier | PrivateIdentifier,
|
||||
callExpression: CallExpression,
|
||||
makeStatic: boolean,
|
||||
inJs: boolean,
|
||||
preferences: UserPreferences,
|
||||
): CodeFixAction | undefined {
|
||||
// Private methods are not implemented yet.
|
||||
if (isPrivateIdentifier(token)) { return undefined; }
|
||||
const changes = textChanges.ChangeTracker.with(context, t => addMethodDeclaration(context, t, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences));
|
||||
return createCodeFixAction(fixName, changes, [makeStatic ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0, token.text], fixId, Diagnostics.Add_all_missing_members);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace ts.codefix {
|
||||
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
|
||||
checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker));
|
||||
const names = map(args, arg =>
|
||||
isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) ? arg.name.text : undefined);
|
||||
isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) && isIdentifier(arg.name) ? arg.name.text : undefined);
|
||||
const contextualType = checker.getContextualType(call);
|
||||
const returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
||||
return createMethod(
|
||||
|
||||
@@ -403,7 +403,7 @@ namespace ts.codefix {
|
||||
entry.kind !== FindAllReferences.EntryKind.Span ? tryCast(entry.node, isIdentifier) : undefined);
|
||||
}
|
||||
|
||||
function inferTypeForVariableFromUsage(token: Identifier, program: Program, cancellationToken: CancellationToken): Type {
|
||||
function inferTypeForVariableFromUsage(token: Identifier | PrivateIdentifier, program: Program, cancellationToken: CancellationToken): Type {
|
||||
const references = getReferences(token, program, cancellationToken);
|
||||
return inferTypeFromReferences(program, references, cancellationToken).single();
|
||||
}
|
||||
|
||||
@@ -2397,8 +2397,10 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const validIdentifierResult: CompletionEntryDisplayNameForSymbol = { name, needsConvertPropertyAccess: false };
|
||||
if (isIdentifierText(name, target)) return validIdentifierResult;
|
||||
const validNameResult: CompletionEntryDisplayNameForSymbol = { name, needsConvertPropertyAccess: false };
|
||||
if (isIdentifierText(name, target) || symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
|
||||
return validNameResult;
|
||||
}
|
||||
switch (kind) {
|
||||
case CompletionKind.MemberLike:
|
||||
return undefined;
|
||||
@@ -2411,7 +2413,7 @@ namespace ts.Completions {
|
||||
return name.charCodeAt(0) === CharacterCodes.space ? undefined : { name, needsConvertPropertyAccess: true };
|
||||
case CompletionKind.None:
|
||||
case CompletionKind.String:
|
||||
return validIdentifierResult;
|
||||
return validNameResult;
|
||||
default:
|
||||
Debug.assertNever(kind);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace ts.NavigationBar {
|
||||
const name = getNameOrArgument(entityName);
|
||||
const nameText = getElementOrPropertyAccessName(entityName);
|
||||
entityName = entityName.expression;
|
||||
if (nameText === "prototype") continue;
|
||||
if (nameText === "prototype" || isPrivateIdentifier(name)) continue;
|
||||
names.push(name);
|
||||
}
|
||||
names.push(entityName);
|
||||
|
||||
@@ -708,7 +708,7 @@ namespace ts.refactor {
|
||||
}
|
||||
|
||||
function nameOfTopLevelDeclaration(d: TopLevelDeclaration): Identifier | undefined {
|
||||
return isExpressionStatement(d) ? d.expression.left.name : tryCast(d.name, isIdentifier);
|
||||
return isExpressionStatement(d) ? tryCast(d.expression.left.name, isIdentifier) : tryCast(d.name, isIdentifier);
|
||||
}
|
||||
|
||||
function getTopLevelDeclarationStatement(d: TopLevelDeclaration): TopLevelDeclarationStatement {
|
||||
|
||||
@@ -2,10 +2,11 @@ namespace ts {
|
||||
/** The version of the language service API */
|
||||
export const servicesVersion = "0.8";
|
||||
|
||||
function createNode<TKind extends SyntaxKind>(kind: TKind, pos: number, end: number, parent: Node): NodeObject | TokenObject<TKind> | IdentifierObject {
|
||||
function createNode<TKind extends SyntaxKind>(kind: TKind, pos: number, end: number, parent: Node): NodeObject | TokenObject<TKind> | IdentifierObject | PrivateIdentifierObject {
|
||||
const node = isNodeKind(kind) ? new NodeObject(kind, pos, end) :
|
||||
kind === SyntaxKind.Identifier ? new IdentifierObject(SyntaxKind.Identifier, pos, end) :
|
||||
new TokenObject(kind, pos, end);
|
||||
kind === SyntaxKind.PrivateIdentifier ? new PrivateIdentifierObject(SyntaxKind.PrivateIdentifier, pos, end) :
|
||||
new TokenObject(kind, pos, end);
|
||||
node.parent = parent;
|
||||
node.flags = parent.flags & NodeFlags.ContextFlags;
|
||||
return node;
|
||||
@@ -368,6 +369,19 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
IdentifierObject.prototype.kind = SyntaxKind.Identifier;
|
||||
class PrivateIdentifierObject extends TokenOrIdentifierObject implements PrivateIdentifier {
|
||||
public kind!: SyntaxKind.PrivateIdentifier;
|
||||
public escapedText!: __String;
|
||||
public symbol!: Symbol;
|
||||
constructor(_kind: SyntaxKind.PrivateIdentifier, pos: number, end: number) {
|
||||
super(pos, end);
|
||||
}
|
||||
|
||||
get text(): string {
|
||||
return idText(this);
|
||||
}
|
||||
}
|
||||
PrivateIdentifierObject.prototype.kind = SyntaxKind.PrivateIdentifier;
|
||||
|
||||
class TypeObject implements Type {
|
||||
checker: TypeChecker;
|
||||
@@ -814,6 +828,7 @@ namespace ts {
|
||||
getTokenConstructor: () => TokenObject,
|
||||
|
||||
getIdentifierConstructor: () => IdentifierObject,
|
||||
getPrivateIdentifierConstructor: () => PrivateIdentifierObject,
|
||||
getSourceFileConstructor: () => SourceFileObject,
|
||||
getSymbolConstructor: () => SymbolObject,
|
||||
getTypeConstructor: () => TypeObject,
|
||||
@@ -2235,6 +2250,10 @@ namespace ts {
|
||||
const text = getEscapedTextOfIdentifierOrLiteral(node);
|
||||
nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1);
|
||||
}
|
||||
else if (isPrivateIdentifier(node)) {
|
||||
const text = node.escapedText;
|
||||
nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1);
|
||||
}
|
||||
|
||||
forEachChild(node, walk);
|
||||
if (hasJSDocNodes(node)) {
|
||||
|
||||
@@ -30,6 +30,10 @@ namespace ts {
|
||||
readonly text: string;
|
||||
}
|
||||
|
||||
export interface PrivateIdentifier {
|
||||
readonly text: string;
|
||||
}
|
||||
|
||||
export interface Symbol {
|
||||
readonly name: string;
|
||||
getFlags(): SymbolFlags;
|
||||
|
||||
@@ -1335,7 +1335,7 @@ namespace ts {
|
||||
return name.kind === SyntaxKind.ComputedPropertyName
|
||||
// treat computed property names where expression is string/numeric literal as just string/numeric literal
|
||||
? isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined
|
||||
: getTextOfIdentifierOrLiteral(name);
|
||||
: isPrivateIdentifier(name) ? idText(name) : getTextOfIdentifierOrLiteral(name);
|
||||
}
|
||||
|
||||
export function programContainsEs6Modules(program: Program): boolean {
|
||||
|
||||
@@ -9,7 +9,7 @@ tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration
|
||||
class C {
|
||||
foo() {
|
||||
// Make sure we don't think of *bar as the start of a generator method.
|
||||
if (a) # * bar;
|
||||
if (a) ¬ * bar;
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
class C {
|
||||
foo() {
|
||||
// Make sure we don't think of *bar as the start of a generator method.
|
||||
if (a) # * bar;
|
||||
if (a) ¬ * bar;
|
||||
return bar;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class C {
|
||||
>foo : Symbol(C.foo, Decl(MemberFunctionDeclaration8_es6.ts, 0, 9))
|
||||
|
||||
// Make sure we don't think of *bar as the start of a generator method.
|
||||
if (a) # * bar;
|
||||
if (a) ¬ * bar;
|
||||
return bar;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class C {
|
||||
>foo : () => any
|
||||
|
||||
// Make sure we don't think of *bar as the start of a generator method.
|
||||
if (a) # * bar;
|
||||
if (a) ¬ * bar;
|
||||
>a : any
|
||||
> : any
|
||||
>* bar : number
|
||||
|
||||
+291
-277
@@ -151,276 +151,277 @@ declare namespace ts {
|
||||
BarEqualsToken = 73,
|
||||
CaretEqualsToken = 74,
|
||||
Identifier = 75,
|
||||
BreakKeyword = 76,
|
||||
CaseKeyword = 77,
|
||||
CatchKeyword = 78,
|
||||
ClassKeyword = 79,
|
||||
ConstKeyword = 80,
|
||||
ContinueKeyword = 81,
|
||||
DebuggerKeyword = 82,
|
||||
DefaultKeyword = 83,
|
||||
DeleteKeyword = 84,
|
||||
DoKeyword = 85,
|
||||
ElseKeyword = 86,
|
||||
EnumKeyword = 87,
|
||||
ExportKeyword = 88,
|
||||
ExtendsKeyword = 89,
|
||||
FalseKeyword = 90,
|
||||
FinallyKeyword = 91,
|
||||
ForKeyword = 92,
|
||||
FunctionKeyword = 93,
|
||||
IfKeyword = 94,
|
||||
ImportKeyword = 95,
|
||||
InKeyword = 96,
|
||||
InstanceOfKeyword = 97,
|
||||
NewKeyword = 98,
|
||||
NullKeyword = 99,
|
||||
ReturnKeyword = 100,
|
||||
SuperKeyword = 101,
|
||||
SwitchKeyword = 102,
|
||||
ThisKeyword = 103,
|
||||
ThrowKeyword = 104,
|
||||
TrueKeyword = 105,
|
||||
TryKeyword = 106,
|
||||
TypeOfKeyword = 107,
|
||||
VarKeyword = 108,
|
||||
VoidKeyword = 109,
|
||||
WhileKeyword = 110,
|
||||
WithKeyword = 111,
|
||||
ImplementsKeyword = 112,
|
||||
InterfaceKeyword = 113,
|
||||
LetKeyword = 114,
|
||||
PackageKeyword = 115,
|
||||
PrivateKeyword = 116,
|
||||
ProtectedKeyword = 117,
|
||||
PublicKeyword = 118,
|
||||
StaticKeyword = 119,
|
||||
YieldKeyword = 120,
|
||||
AbstractKeyword = 121,
|
||||
AsKeyword = 122,
|
||||
AssertsKeyword = 123,
|
||||
AnyKeyword = 124,
|
||||
AsyncKeyword = 125,
|
||||
AwaitKeyword = 126,
|
||||
BooleanKeyword = 127,
|
||||
ConstructorKeyword = 128,
|
||||
DeclareKeyword = 129,
|
||||
GetKeyword = 130,
|
||||
InferKeyword = 131,
|
||||
IsKeyword = 132,
|
||||
KeyOfKeyword = 133,
|
||||
ModuleKeyword = 134,
|
||||
NamespaceKeyword = 135,
|
||||
NeverKeyword = 136,
|
||||
ReadonlyKeyword = 137,
|
||||
RequireKeyword = 138,
|
||||
NumberKeyword = 139,
|
||||
ObjectKeyword = 140,
|
||||
SetKeyword = 141,
|
||||
StringKeyword = 142,
|
||||
SymbolKeyword = 143,
|
||||
TypeKeyword = 144,
|
||||
UndefinedKeyword = 145,
|
||||
UniqueKeyword = 146,
|
||||
UnknownKeyword = 147,
|
||||
FromKeyword = 148,
|
||||
GlobalKeyword = 149,
|
||||
BigIntKeyword = 150,
|
||||
OfKeyword = 151,
|
||||
QualifiedName = 152,
|
||||
ComputedPropertyName = 153,
|
||||
TypeParameter = 154,
|
||||
Parameter = 155,
|
||||
Decorator = 156,
|
||||
PropertySignature = 157,
|
||||
PropertyDeclaration = 158,
|
||||
MethodSignature = 159,
|
||||
MethodDeclaration = 160,
|
||||
Constructor = 161,
|
||||
GetAccessor = 162,
|
||||
SetAccessor = 163,
|
||||
CallSignature = 164,
|
||||
ConstructSignature = 165,
|
||||
IndexSignature = 166,
|
||||
TypePredicate = 167,
|
||||
TypeReference = 168,
|
||||
FunctionType = 169,
|
||||
ConstructorType = 170,
|
||||
TypeQuery = 171,
|
||||
TypeLiteral = 172,
|
||||
ArrayType = 173,
|
||||
TupleType = 174,
|
||||
OptionalType = 175,
|
||||
RestType = 176,
|
||||
UnionType = 177,
|
||||
IntersectionType = 178,
|
||||
ConditionalType = 179,
|
||||
InferType = 180,
|
||||
ParenthesizedType = 181,
|
||||
ThisType = 182,
|
||||
TypeOperator = 183,
|
||||
IndexedAccessType = 184,
|
||||
MappedType = 185,
|
||||
LiteralType = 186,
|
||||
ImportType = 187,
|
||||
ObjectBindingPattern = 188,
|
||||
ArrayBindingPattern = 189,
|
||||
BindingElement = 190,
|
||||
ArrayLiteralExpression = 191,
|
||||
ObjectLiteralExpression = 192,
|
||||
PropertyAccessExpression = 193,
|
||||
ElementAccessExpression = 194,
|
||||
CallExpression = 195,
|
||||
NewExpression = 196,
|
||||
TaggedTemplateExpression = 197,
|
||||
TypeAssertionExpression = 198,
|
||||
ParenthesizedExpression = 199,
|
||||
FunctionExpression = 200,
|
||||
ArrowFunction = 201,
|
||||
DeleteExpression = 202,
|
||||
TypeOfExpression = 203,
|
||||
VoidExpression = 204,
|
||||
AwaitExpression = 205,
|
||||
PrefixUnaryExpression = 206,
|
||||
PostfixUnaryExpression = 207,
|
||||
BinaryExpression = 208,
|
||||
ConditionalExpression = 209,
|
||||
TemplateExpression = 210,
|
||||
YieldExpression = 211,
|
||||
SpreadElement = 212,
|
||||
ClassExpression = 213,
|
||||
OmittedExpression = 214,
|
||||
ExpressionWithTypeArguments = 215,
|
||||
AsExpression = 216,
|
||||
NonNullExpression = 217,
|
||||
MetaProperty = 218,
|
||||
SyntheticExpression = 219,
|
||||
TemplateSpan = 220,
|
||||
SemicolonClassElement = 221,
|
||||
Block = 222,
|
||||
EmptyStatement = 223,
|
||||
VariableStatement = 224,
|
||||
ExpressionStatement = 225,
|
||||
IfStatement = 226,
|
||||
DoStatement = 227,
|
||||
WhileStatement = 228,
|
||||
ForStatement = 229,
|
||||
ForInStatement = 230,
|
||||
ForOfStatement = 231,
|
||||
ContinueStatement = 232,
|
||||
BreakStatement = 233,
|
||||
ReturnStatement = 234,
|
||||
WithStatement = 235,
|
||||
SwitchStatement = 236,
|
||||
LabeledStatement = 237,
|
||||
ThrowStatement = 238,
|
||||
TryStatement = 239,
|
||||
DebuggerStatement = 240,
|
||||
VariableDeclaration = 241,
|
||||
VariableDeclarationList = 242,
|
||||
FunctionDeclaration = 243,
|
||||
ClassDeclaration = 244,
|
||||
InterfaceDeclaration = 245,
|
||||
TypeAliasDeclaration = 246,
|
||||
EnumDeclaration = 247,
|
||||
ModuleDeclaration = 248,
|
||||
ModuleBlock = 249,
|
||||
CaseBlock = 250,
|
||||
NamespaceExportDeclaration = 251,
|
||||
ImportEqualsDeclaration = 252,
|
||||
ImportDeclaration = 253,
|
||||
ImportClause = 254,
|
||||
NamespaceImport = 255,
|
||||
NamedImports = 256,
|
||||
ImportSpecifier = 257,
|
||||
ExportAssignment = 258,
|
||||
ExportDeclaration = 259,
|
||||
NamedExports = 260,
|
||||
NamespaceExport = 261,
|
||||
ExportSpecifier = 262,
|
||||
MissingDeclaration = 263,
|
||||
ExternalModuleReference = 264,
|
||||
JsxElement = 265,
|
||||
JsxSelfClosingElement = 266,
|
||||
JsxOpeningElement = 267,
|
||||
JsxClosingElement = 268,
|
||||
JsxFragment = 269,
|
||||
JsxOpeningFragment = 270,
|
||||
JsxClosingFragment = 271,
|
||||
JsxAttribute = 272,
|
||||
JsxAttributes = 273,
|
||||
JsxSpreadAttribute = 274,
|
||||
JsxExpression = 275,
|
||||
CaseClause = 276,
|
||||
DefaultClause = 277,
|
||||
HeritageClause = 278,
|
||||
CatchClause = 279,
|
||||
PropertyAssignment = 280,
|
||||
ShorthandPropertyAssignment = 281,
|
||||
SpreadAssignment = 282,
|
||||
EnumMember = 283,
|
||||
UnparsedPrologue = 284,
|
||||
UnparsedPrepend = 285,
|
||||
UnparsedText = 286,
|
||||
UnparsedInternalText = 287,
|
||||
UnparsedSyntheticReference = 288,
|
||||
SourceFile = 289,
|
||||
Bundle = 290,
|
||||
UnparsedSource = 291,
|
||||
InputFiles = 292,
|
||||
JSDocTypeExpression = 293,
|
||||
JSDocAllType = 294,
|
||||
JSDocUnknownType = 295,
|
||||
JSDocNullableType = 296,
|
||||
JSDocNonNullableType = 297,
|
||||
JSDocOptionalType = 298,
|
||||
JSDocFunctionType = 299,
|
||||
JSDocVariadicType = 300,
|
||||
JSDocNamepathType = 301,
|
||||
JSDocComment = 302,
|
||||
JSDocTypeLiteral = 303,
|
||||
JSDocSignature = 304,
|
||||
JSDocTag = 305,
|
||||
JSDocAugmentsTag = 306,
|
||||
JSDocAuthorTag = 307,
|
||||
JSDocClassTag = 308,
|
||||
JSDocPublicTag = 309,
|
||||
JSDocPrivateTag = 310,
|
||||
JSDocProtectedTag = 311,
|
||||
JSDocReadonlyTag = 312,
|
||||
JSDocCallbackTag = 313,
|
||||
JSDocEnumTag = 314,
|
||||
JSDocParameterTag = 315,
|
||||
JSDocReturnTag = 316,
|
||||
JSDocThisTag = 317,
|
||||
JSDocTypeTag = 318,
|
||||
JSDocTemplateTag = 319,
|
||||
JSDocTypedefTag = 320,
|
||||
JSDocPropertyTag = 321,
|
||||
SyntaxList = 322,
|
||||
NotEmittedStatement = 323,
|
||||
PartiallyEmittedExpression = 324,
|
||||
CommaListExpression = 325,
|
||||
MergeDeclarationMarker = 326,
|
||||
EndOfDeclarationMarker = 327,
|
||||
SyntheticReferenceExpression = 328,
|
||||
Count = 329,
|
||||
PrivateIdentifier = 76,
|
||||
BreakKeyword = 77,
|
||||
CaseKeyword = 78,
|
||||
CatchKeyword = 79,
|
||||
ClassKeyword = 80,
|
||||
ConstKeyword = 81,
|
||||
ContinueKeyword = 82,
|
||||
DebuggerKeyword = 83,
|
||||
DefaultKeyword = 84,
|
||||
DeleteKeyword = 85,
|
||||
DoKeyword = 86,
|
||||
ElseKeyword = 87,
|
||||
EnumKeyword = 88,
|
||||
ExportKeyword = 89,
|
||||
ExtendsKeyword = 90,
|
||||
FalseKeyword = 91,
|
||||
FinallyKeyword = 92,
|
||||
ForKeyword = 93,
|
||||
FunctionKeyword = 94,
|
||||
IfKeyword = 95,
|
||||
ImportKeyword = 96,
|
||||
InKeyword = 97,
|
||||
InstanceOfKeyword = 98,
|
||||
NewKeyword = 99,
|
||||
NullKeyword = 100,
|
||||
ReturnKeyword = 101,
|
||||
SuperKeyword = 102,
|
||||
SwitchKeyword = 103,
|
||||
ThisKeyword = 104,
|
||||
ThrowKeyword = 105,
|
||||
TrueKeyword = 106,
|
||||
TryKeyword = 107,
|
||||
TypeOfKeyword = 108,
|
||||
VarKeyword = 109,
|
||||
VoidKeyword = 110,
|
||||
WhileKeyword = 111,
|
||||
WithKeyword = 112,
|
||||
ImplementsKeyword = 113,
|
||||
InterfaceKeyword = 114,
|
||||
LetKeyword = 115,
|
||||
PackageKeyword = 116,
|
||||
PrivateKeyword = 117,
|
||||
ProtectedKeyword = 118,
|
||||
PublicKeyword = 119,
|
||||
StaticKeyword = 120,
|
||||
YieldKeyword = 121,
|
||||
AbstractKeyword = 122,
|
||||
AsKeyword = 123,
|
||||
AssertsKeyword = 124,
|
||||
AnyKeyword = 125,
|
||||
AsyncKeyword = 126,
|
||||
AwaitKeyword = 127,
|
||||
BooleanKeyword = 128,
|
||||
ConstructorKeyword = 129,
|
||||
DeclareKeyword = 130,
|
||||
GetKeyword = 131,
|
||||
InferKeyword = 132,
|
||||
IsKeyword = 133,
|
||||
KeyOfKeyword = 134,
|
||||
ModuleKeyword = 135,
|
||||
NamespaceKeyword = 136,
|
||||
NeverKeyword = 137,
|
||||
ReadonlyKeyword = 138,
|
||||
RequireKeyword = 139,
|
||||
NumberKeyword = 140,
|
||||
ObjectKeyword = 141,
|
||||
SetKeyword = 142,
|
||||
StringKeyword = 143,
|
||||
SymbolKeyword = 144,
|
||||
TypeKeyword = 145,
|
||||
UndefinedKeyword = 146,
|
||||
UniqueKeyword = 147,
|
||||
UnknownKeyword = 148,
|
||||
FromKeyword = 149,
|
||||
GlobalKeyword = 150,
|
||||
BigIntKeyword = 151,
|
||||
OfKeyword = 152,
|
||||
QualifiedName = 153,
|
||||
ComputedPropertyName = 154,
|
||||
TypeParameter = 155,
|
||||
Parameter = 156,
|
||||
Decorator = 157,
|
||||
PropertySignature = 158,
|
||||
PropertyDeclaration = 159,
|
||||
MethodSignature = 160,
|
||||
MethodDeclaration = 161,
|
||||
Constructor = 162,
|
||||
GetAccessor = 163,
|
||||
SetAccessor = 164,
|
||||
CallSignature = 165,
|
||||
ConstructSignature = 166,
|
||||
IndexSignature = 167,
|
||||
TypePredicate = 168,
|
||||
TypeReference = 169,
|
||||
FunctionType = 170,
|
||||
ConstructorType = 171,
|
||||
TypeQuery = 172,
|
||||
TypeLiteral = 173,
|
||||
ArrayType = 174,
|
||||
TupleType = 175,
|
||||
OptionalType = 176,
|
||||
RestType = 177,
|
||||
UnionType = 178,
|
||||
IntersectionType = 179,
|
||||
ConditionalType = 180,
|
||||
InferType = 181,
|
||||
ParenthesizedType = 182,
|
||||
ThisType = 183,
|
||||
TypeOperator = 184,
|
||||
IndexedAccessType = 185,
|
||||
MappedType = 186,
|
||||
LiteralType = 187,
|
||||
ImportType = 188,
|
||||
ObjectBindingPattern = 189,
|
||||
ArrayBindingPattern = 190,
|
||||
BindingElement = 191,
|
||||
ArrayLiteralExpression = 192,
|
||||
ObjectLiteralExpression = 193,
|
||||
PropertyAccessExpression = 194,
|
||||
ElementAccessExpression = 195,
|
||||
CallExpression = 196,
|
||||
NewExpression = 197,
|
||||
TaggedTemplateExpression = 198,
|
||||
TypeAssertionExpression = 199,
|
||||
ParenthesizedExpression = 200,
|
||||
FunctionExpression = 201,
|
||||
ArrowFunction = 202,
|
||||
DeleteExpression = 203,
|
||||
TypeOfExpression = 204,
|
||||
VoidExpression = 205,
|
||||
AwaitExpression = 206,
|
||||
PrefixUnaryExpression = 207,
|
||||
PostfixUnaryExpression = 208,
|
||||
BinaryExpression = 209,
|
||||
ConditionalExpression = 210,
|
||||
TemplateExpression = 211,
|
||||
YieldExpression = 212,
|
||||
SpreadElement = 213,
|
||||
ClassExpression = 214,
|
||||
OmittedExpression = 215,
|
||||
ExpressionWithTypeArguments = 216,
|
||||
AsExpression = 217,
|
||||
NonNullExpression = 218,
|
||||
MetaProperty = 219,
|
||||
SyntheticExpression = 220,
|
||||
TemplateSpan = 221,
|
||||
SemicolonClassElement = 222,
|
||||
Block = 223,
|
||||
EmptyStatement = 224,
|
||||
VariableStatement = 225,
|
||||
ExpressionStatement = 226,
|
||||
IfStatement = 227,
|
||||
DoStatement = 228,
|
||||
WhileStatement = 229,
|
||||
ForStatement = 230,
|
||||
ForInStatement = 231,
|
||||
ForOfStatement = 232,
|
||||
ContinueStatement = 233,
|
||||
BreakStatement = 234,
|
||||
ReturnStatement = 235,
|
||||
WithStatement = 236,
|
||||
SwitchStatement = 237,
|
||||
LabeledStatement = 238,
|
||||
ThrowStatement = 239,
|
||||
TryStatement = 240,
|
||||
DebuggerStatement = 241,
|
||||
VariableDeclaration = 242,
|
||||
VariableDeclarationList = 243,
|
||||
FunctionDeclaration = 244,
|
||||
ClassDeclaration = 245,
|
||||
InterfaceDeclaration = 246,
|
||||
TypeAliasDeclaration = 247,
|
||||
EnumDeclaration = 248,
|
||||
ModuleDeclaration = 249,
|
||||
ModuleBlock = 250,
|
||||
CaseBlock = 251,
|
||||
NamespaceExportDeclaration = 252,
|
||||
ImportEqualsDeclaration = 253,
|
||||
ImportDeclaration = 254,
|
||||
ImportClause = 255,
|
||||
NamespaceImport = 256,
|
||||
NamedImports = 257,
|
||||
ImportSpecifier = 258,
|
||||
ExportAssignment = 259,
|
||||
ExportDeclaration = 260,
|
||||
NamedExports = 261,
|
||||
NamespaceExport = 262,
|
||||
ExportSpecifier = 263,
|
||||
MissingDeclaration = 264,
|
||||
ExternalModuleReference = 265,
|
||||
JsxElement = 266,
|
||||
JsxSelfClosingElement = 267,
|
||||
JsxOpeningElement = 268,
|
||||
JsxClosingElement = 269,
|
||||
JsxFragment = 270,
|
||||
JsxOpeningFragment = 271,
|
||||
JsxClosingFragment = 272,
|
||||
JsxAttribute = 273,
|
||||
JsxAttributes = 274,
|
||||
JsxSpreadAttribute = 275,
|
||||
JsxExpression = 276,
|
||||
CaseClause = 277,
|
||||
DefaultClause = 278,
|
||||
HeritageClause = 279,
|
||||
CatchClause = 280,
|
||||
PropertyAssignment = 281,
|
||||
ShorthandPropertyAssignment = 282,
|
||||
SpreadAssignment = 283,
|
||||
EnumMember = 284,
|
||||
UnparsedPrologue = 285,
|
||||
UnparsedPrepend = 286,
|
||||
UnparsedText = 287,
|
||||
UnparsedInternalText = 288,
|
||||
UnparsedSyntheticReference = 289,
|
||||
SourceFile = 290,
|
||||
Bundle = 291,
|
||||
UnparsedSource = 292,
|
||||
InputFiles = 293,
|
||||
JSDocTypeExpression = 294,
|
||||
JSDocAllType = 295,
|
||||
JSDocUnknownType = 296,
|
||||
JSDocNullableType = 297,
|
||||
JSDocNonNullableType = 298,
|
||||
JSDocOptionalType = 299,
|
||||
JSDocFunctionType = 300,
|
||||
JSDocVariadicType = 301,
|
||||
JSDocNamepathType = 302,
|
||||
JSDocComment = 303,
|
||||
JSDocTypeLiteral = 304,
|
||||
JSDocSignature = 305,
|
||||
JSDocTag = 306,
|
||||
JSDocAugmentsTag = 307,
|
||||
JSDocAuthorTag = 308,
|
||||
JSDocClassTag = 309,
|
||||
JSDocPublicTag = 310,
|
||||
JSDocPrivateTag = 311,
|
||||
JSDocProtectedTag = 312,
|
||||
JSDocReadonlyTag = 313,
|
||||
JSDocCallbackTag = 314,
|
||||
JSDocEnumTag = 315,
|
||||
JSDocParameterTag = 316,
|
||||
JSDocReturnTag = 317,
|
||||
JSDocThisTag = 318,
|
||||
JSDocTypeTag = 319,
|
||||
JSDocTemplateTag = 320,
|
||||
JSDocTypedefTag = 321,
|
||||
JSDocPropertyTag = 322,
|
||||
SyntaxList = 323,
|
||||
NotEmittedStatement = 324,
|
||||
PartiallyEmittedExpression = 325,
|
||||
CommaListExpression = 326,
|
||||
MergeDeclarationMarker = 327,
|
||||
EndOfDeclarationMarker = 328,
|
||||
SyntheticReferenceExpression = 329,
|
||||
Count = 330,
|
||||
FirstAssignment = 62,
|
||||
LastAssignment = 74,
|
||||
FirstCompoundAssignment = 63,
|
||||
LastCompoundAssignment = 74,
|
||||
FirstReservedWord = 76,
|
||||
LastReservedWord = 111,
|
||||
FirstKeyword = 76,
|
||||
LastKeyword = 151,
|
||||
FirstFutureReservedWord = 112,
|
||||
LastFutureReservedWord = 120,
|
||||
FirstTypeNode = 167,
|
||||
LastTypeNode = 187,
|
||||
FirstReservedWord = 77,
|
||||
LastReservedWord = 112,
|
||||
FirstKeyword = 77,
|
||||
LastKeyword = 152,
|
||||
FirstFutureReservedWord = 113,
|
||||
LastFutureReservedWord = 121,
|
||||
FirstTypeNode = 168,
|
||||
LastTypeNode = 188,
|
||||
FirstPunctuation = 18,
|
||||
LastPunctuation = 74,
|
||||
FirstToken = 0,
|
||||
LastToken = 151,
|
||||
LastToken = 152,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -429,13 +430,13 @@ declare namespace ts {
|
||||
LastTemplateToken = 17,
|
||||
FirstBinaryOperator = 29,
|
||||
LastBinaryOperator = 74,
|
||||
FirstStatement = 224,
|
||||
LastStatement = 240,
|
||||
FirstNode = 152,
|
||||
FirstJSDocNode = 293,
|
||||
LastJSDocNode = 321,
|
||||
FirstJSDocTagNode = 305,
|
||||
LastJSDocTagNode = 321,
|
||||
FirstStatement = 225,
|
||||
LastStatement = 241,
|
||||
FirstNode = 153,
|
||||
FirstJSDocNode = 294,
|
||||
LastJSDocNode = 322,
|
||||
FirstJSDocTagNode = 306,
|
||||
LastJSDocTagNode = 322,
|
||||
}
|
||||
export enum NodeFlags {
|
||||
None = 0,
|
||||
@@ -552,8 +553,8 @@ declare namespace ts {
|
||||
right: Identifier;
|
||||
}
|
||||
export type EntityName = Identifier | QualifiedName;
|
||||
export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName;
|
||||
export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression;
|
||||
export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier;
|
||||
export type DeclarationName = Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression;
|
||||
export interface Declaration extends Node {
|
||||
_declarationBrand: any;
|
||||
}
|
||||
@@ -568,6 +569,10 @@ declare namespace ts {
|
||||
kind: SyntaxKind.ComputedPropertyName;
|
||||
expression: Expression;
|
||||
}
|
||||
export interface PrivateIdentifier extends Node {
|
||||
kind: SyntaxKind.PrivateIdentifier;
|
||||
escapedText: __String;
|
||||
}
|
||||
export interface Decorator extends Node {
|
||||
kind: SyntaxKind.Decorator;
|
||||
parent: NamedDeclaration;
|
||||
@@ -1093,10 +1098,11 @@ declare namespace ts {
|
||||
kind: SyntaxKind.PropertyAccessExpression;
|
||||
expression: LeftHandSideExpression;
|
||||
questionDotToken?: QuestionDotToken;
|
||||
name: Identifier;
|
||||
name: Identifier | PrivateIdentifier;
|
||||
}
|
||||
export interface PropertyAccessChain extends PropertyAccessExpression {
|
||||
_optionalChainBrand: any;
|
||||
name: Identifier;
|
||||
}
|
||||
export interface SuperPropertyAccessExpression extends PropertyAccessExpression {
|
||||
expression: SuperExpression;
|
||||
@@ -1105,6 +1111,7 @@ declare namespace ts {
|
||||
export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression {
|
||||
_propertyAccessExpressionLikeQualifiedNameBrand?: any;
|
||||
expression: EntityNameExpression;
|
||||
name: Identifier;
|
||||
}
|
||||
export interface ElementAccessExpression extends MemberExpression {
|
||||
kind: SyntaxKind.ElementAccessExpression;
|
||||
@@ -2002,6 +2009,7 @@ declare namespace ts {
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
|
||||
getPrivateIdentifierPropertyOfType(leftType: Type, name: string, location: Node): Symbol | undefined;
|
||||
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined;
|
||||
getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[];
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined;
|
||||
@@ -3440,9 +3448,9 @@ declare namespace ts {
|
||||
* @returns The unescaped identifier text.
|
||||
*/
|
||||
function unescapeLeadingUnderscores(identifier: __String): string;
|
||||
function idText(identifier: Identifier): string;
|
||||
function idText(identifierOrPrivateName: Identifier | PrivateIdentifier): string;
|
||||
function symbolName(symbol: Symbol): string;
|
||||
function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined;
|
||||
function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined;
|
||||
function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined;
|
||||
/**
|
||||
* Gets the JSDoc parameter tags for the node if present.
|
||||
@@ -3538,6 +3546,8 @@ declare namespace ts {
|
||||
function isIdentifier(node: Node): node is Identifier;
|
||||
function isQualifiedName(node: Node): node is QualifiedName;
|
||||
function isComputedPropertyName(node: Node): node is ComputedPropertyName;
|
||||
function isPrivateIdentifier(node: Node): node is PrivateIdentifier;
|
||||
function isIdentifierOrPrivateIdentifier(node: Node): node is Identifier | PrivateIdentifier;
|
||||
function isTypeParameterDeclaration(node: Node): node is TypeParameterDeclaration;
|
||||
function isParameter(node: Node): node is ParameterDeclaration;
|
||||
function isDecorator(node: Node): node is Decorator;
|
||||
@@ -3937,6 +3947,7 @@ declare namespace ts {
|
||||
function createFileLevelUniqueName(text: string): Identifier;
|
||||
/** Create a unique name generated for a node. */
|
||||
function getGeneratedNameForNode(node: Node | undefined): Identifier;
|
||||
function createPrivateIdentifier(text: string): PrivateIdentifier;
|
||||
function createToken<TKind extends SyntaxKind>(token: TKind): Token<TKind>;
|
||||
function createSuper(): SuperExpression;
|
||||
function createThis(): ThisExpression & Token<SyntaxKind.ThisKeyword>;
|
||||
@@ -4031,8 +4042,8 @@ declare namespace ts {
|
||||
function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression;
|
||||
function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression;
|
||||
function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression;
|
||||
function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression;
|
||||
function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression;
|
||||
function createPropertyAccess(expression: Expression, name: string | Identifier | PrivateIdentifier): PropertyAccessExpression;
|
||||
function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier): PropertyAccessExpression;
|
||||
function createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier): PropertyAccessChain;
|
||||
function updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier): PropertyAccessChain;
|
||||
function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression;
|
||||
@@ -4942,6 +4953,9 @@ declare namespace ts {
|
||||
interface Identifier {
|
||||
readonly text: string;
|
||||
}
|
||||
interface PrivateIdentifier {
|
||||
readonly text: string;
|
||||
}
|
||||
interface Symbol {
|
||||
readonly name: string;
|
||||
getFlags(): SymbolFlags;
|
||||
|
||||
+291
-277
@@ -151,276 +151,277 @@ declare namespace ts {
|
||||
BarEqualsToken = 73,
|
||||
CaretEqualsToken = 74,
|
||||
Identifier = 75,
|
||||
BreakKeyword = 76,
|
||||
CaseKeyword = 77,
|
||||
CatchKeyword = 78,
|
||||
ClassKeyword = 79,
|
||||
ConstKeyword = 80,
|
||||
ContinueKeyword = 81,
|
||||
DebuggerKeyword = 82,
|
||||
DefaultKeyword = 83,
|
||||
DeleteKeyword = 84,
|
||||
DoKeyword = 85,
|
||||
ElseKeyword = 86,
|
||||
EnumKeyword = 87,
|
||||
ExportKeyword = 88,
|
||||
ExtendsKeyword = 89,
|
||||
FalseKeyword = 90,
|
||||
FinallyKeyword = 91,
|
||||
ForKeyword = 92,
|
||||
FunctionKeyword = 93,
|
||||
IfKeyword = 94,
|
||||
ImportKeyword = 95,
|
||||
InKeyword = 96,
|
||||
InstanceOfKeyword = 97,
|
||||
NewKeyword = 98,
|
||||
NullKeyword = 99,
|
||||
ReturnKeyword = 100,
|
||||
SuperKeyword = 101,
|
||||
SwitchKeyword = 102,
|
||||
ThisKeyword = 103,
|
||||
ThrowKeyword = 104,
|
||||
TrueKeyword = 105,
|
||||
TryKeyword = 106,
|
||||
TypeOfKeyword = 107,
|
||||
VarKeyword = 108,
|
||||
VoidKeyword = 109,
|
||||
WhileKeyword = 110,
|
||||
WithKeyword = 111,
|
||||
ImplementsKeyword = 112,
|
||||
InterfaceKeyword = 113,
|
||||
LetKeyword = 114,
|
||||
PackageKeyword = 115,
|
||||
PrivateKeyword = 116,
|
||||
ProtectedKeyword = 117,
|
||||
PublicKeyword = 118,
|
||||
StaticKeyword = 119,
|
||||
YieldKeyword = 120,
|
||||
AbstractKeyword = 121,
|
||||
AsKeyword = 122,
|
||||
AssertsKeyword = 123,
|
||||
AnyKeyword = 124,
|
||||
AsyncKeyword = 125,
|
||||
AwaitKeyword = 126,
|
||||
BooleanKeyword = 127,
|
||||
ConstructorKeyword = 128,
|
||||
DeclareKeyword = 129,
|
||||
GetKeyword = 130,
|
||||
InferKeyword = 131,
|
||||
IsKeyword = 132,
|
||||
KeyOfKeyword = 133,
|
||||
ModuleKeyword = 134,
|
||||
NamespaceKeyword = 135,
|
||||
NeverKeyword = 136,
|
||||
ReadonlyKeyword = 137,
|
||||
RequireKeyword = 138,
|
||||
NumberKeyword = 139,
|
||||
ObjectKeyword = 140,
|
||||
SetKeyword = 141,
|
||||
StringKeyword = 142,
|
||||
SymbolKeyword = 143,
|
||||
TypeKeyword = 144,
|
||||
UndefinedKeyword = 145,
|
||||
UniqueKeyword = 146,
|
||||
UnknownKeyword = 147,
|
||||
FromKeyword = 148,
|
||||
GlobalKeyword = 149,
|
||||
BigIntKeyword = 150,
|
||||
OfKeyword = 151,
|
||||
QualifiedName = 152,
|
||||
ComputedPropertyName = 153,
|
||||
TypeParameter = 154,
|
||||
Parameter = 155,
|
||||
Decorator = 156,
|
||||
PropertySignature = 157,
|
||||
PropertyDeclaration = 158,
|
||||
MethodSignature = 159,
|
||||
MethodDeclaration = 160,
|
||||
Constructor = 161,
|
||||
GetAccessor = 162,
|
||||
SetAccessor = 163,
|
||||
CallSignature = 164,
|
||||
ConstructSignature = 165,
|
||||
IndexSignature = 166,
|
||||
TypePredicate = 167,
|
||||
TypeReference = 168,
|
||||
FunctionType = 169,
|
||||
ConstructorType = 170,
|
||||
TypeQuery = 171,
|
||||
TypeLiteral = 172,
|
||||
ArrayType = 173,
|
||||
TupleType = 174,
|
||||
OptionalType = 175,
|
||||
RestType = 176,
|
||||
UnionType = 177,
|
||||
IntersectionType = 178,
|
||||
ConditionalType = 179,
|
||||
InferType = 180,
|
||||
ParenthesizedType = 181,
|
||||
ThisType = 182,
|
||||
TypeOperator = 183,
|
||||
IndexedAccessType = 184,
|
||||
MappedType = 185,
|
||||
LiteralType = 186,
|
||||
ImportType = 187,
|
||||
ObjectBindingPattern = 188,
|
||||
ArrayBindingPattern = 189,
|
||||
BindingElement = 190,
|
||||
ArrayLiteralExpression = 191,
|
||||
ObjectLiteralExpression = 192,
|
||||
PropertyAccessExpression = 193,
|
||||
ElementAccessExpression = 194,
|
||||
CallExpression = 195,
|
||||
NewExpression = 196,
|
||||
TaggedTemplateExpression = 197,
|
||||
TypeAssertionExpression = 198,
|
||||
ParenthesizedExpression = 199,
|
||||
FunctionExpression = 200,
|
||||
ArrowFunction = 201,
|
||||
DeleteExpression = 202,
|
||||
TypeOfExpression = 203,
|
||||
VoidExpression = 204,
|
||||
AwaitExpression = 205,
|
||||
PrefixUnaryExpression = 206,
|
||||
PostfixUnaryExpression = 207,
|
||||
BinaryExpression = 208,
|
||||
ConditionalExpression = 209,
|
||||
TemplateExpression = 210,
|
||||
YieldExpression = 211,
|
||||
SpreadElement = 212,
|
||||
ClassExpression = 213,
|
||||
OmittedExpression = 214,
|
||||
ExpressionWithTypeArguments = 215,
|
||||
AsExpression = 216,
|
||||
NonNullExpression = 217,
|
||||
MetaProperty = 218,
|
||||
SyntheticExpression = 219,
|
||||
TemplateSpan = 220,
|
||||
SemicolonClassElement = 221,
|
||||
Block = 222,
|
||||
EmptyStatement = 223,
|
||||
VariableStatement = 224,
|
||||
ExpressionStatement = 225,
|
||||
IfStatement = 226,
|
||||
DoStatement = 227,
|
||||
WhileStatement = 228,
|
||||
ForStatement = 229,
|
||||
ForInStatement = 230,
|
||||
ForOfStatement = 231,
|
||||
ContinueStatement = 232,
|
||||
BreakStatement = 233,
|
||||
ReturnStatement = 234,
|
||||
WithStatement = 235,
|
||||
SwitchStatement = 236,
|
||||
LabeledStatement = 237,
|
||||
ThrowStatement = 238,
|
||||
TryStatement = 239,
|
||||
DebuggerStatement = 240,
|
||||
VariableDeclaration = 241,
|
||||
VariableDeclarationList = 242,
|
||||
FunctionDeclaration = 243,
|
||||
ClassDeclaration = 244,
|
||||
InterfaceDeclaration = 245,
|
||||
TypeAliasDeclaration = 246,
|
||||
EnumDeclaration = 247,
|
||||
ModuleDeclaration = 248,
|
||||
ModuleBlock = 249,
|
||||
CaseBlock = 250,
|
||||
NamespaceExportDeclaration = 251,
|
||||
ImportEqualsDeclaration = 252,
|
||||
ImportDeclaration = 253,
|
||||
ImportClause = 254,
|
||||
NamespaceImport = 255,
|
||||
NamedImports = 256,
|
||||
ImportSpecifier = 257,
|
||||
ExportAssignment = 258,
|
||||
ExportDeclaration = 259,
|
||||
NamedExports = 260,
|
||||
NamespaceExport = 261,
|
||||
ExportSpecifier = 262,
|
||||
MissingDeclaration = 263,
|
||||
ExternalModuleReference = 264,
|
||||
JsxElement = 265,
|
||||
JsxSelfClosingElement = 266,
|
||||
JsxOpeningElement = 267,
|
||||
JsxClosingElement = 268,
|
||||
JsxFragment = 269,
|
||||
JsxOpeningFragment = 270,
|
||||
JsxClosingFragment = 271,
|
||||
JsxAttribute = 272,
|
||||
JsxAttributes = 273,
|
||||
JsxSpreadAttribute = 274,
|
||||
JsxExpression = 275,
|
||||
CaseClause = 276,
|
||||
DefaultClause = 277,
|
||||
HeritageClause = 278,
|
||||
CatchClause = 279,
|
||||
PropertyAssignment = 280,
|
||||
ShorthandPropertyAssignment = 281,
|
||||
SpreadAssignment = 282,
|
||||
EnumMember = 283,
|
||||
UnparsedPrologue = 284,
|
||||
UnparsedPrepend = 285,
|
||||
UnparsedText = 286,
|
||||
UnparsedInternalText = 287,
|
||||
UnparsedSyntheticReference = 288,
|
||||
SourceFile = 289,
|
||||
Bundle = 290,
|
||||
UnparsedSource = 291,
|
||||
InputFiles = 292,
|
||||
JSDocTypeExpression = 293,
|
||||
JSDocAllType = 294,
|
||||
JSDocUnknownType = 295,
|
||||
JSDocNullableType = 296,
|
||||
JSDocNonNullableType = 297,
|
||||
JSDocOptionalType = 298,
|
||||
JSDocFunctionType = 299,
|
||||
JSDocVariadicType = 300,
|
||||
JSDocNamepathType = 301,
|
||||
JSDocComment = 302,
|
||||
JSDocTypeLiteral = 303,
|
||||
JSDocSignature = 304,
|
||||
JSDocTag = 305,
|
||||
JSDocAugmentsTag = 306,
|
||||
JSDocAuthorTag = 307,
|
||||
JSDocClassTag = 308,
|
||||
JSDocPublicTag = 309,
|
||||
JSDocPrivateTag = 310,
|
||||
JSDocProtectedTag = 311,
|
||||
JSDocReadonlyTag = 312,
|
||||
JSDocCallbackTag = 313,
|
||||
JSDocEnumTag = 314,
|
||||
JSDocParameterTag = 315,
|
||||
JSDocReturnTag = 316,
|
||||
JSDocThisTag = 317,
|
||||
JSDocTypeTag = 318,
|
||||
JSDocTemplateTag = 319,
|
||||
JSDocTypedefTag = 320,
|
||||
JSDocPropertyTag = 321,
|
||||
SyntaxList = 322,
|
||||
NotEmittedStatement = 323,
|
||||
PartiallyEmittedExpression = 324,
|
||||
CommaListExpression = 325,
|
||||
MergeDeclarationMarker = 326,
|
||||
EndOfDeclarationMarker = 327,
|
||||
SyntheticReferenceExpression = 328,
|
||||
Count = 329,
|
||||
PrivateIdentifier = 76,
|
||||
BreakKeyword = 77,
|
||||
CaseKeyword = 78,
|
||||
CatchKeyword = 79,
|
||||
ClassKeyword = 80,
|
||||
ConstKeyword = 81,
|
||||
ContinueKeyword = 82,
|
||||
DebuggerKeyword = 83,
|
||||
DefaultKeyword = 84,
|
||||
DeleteKeyword = 85,
|
||||
DoKeyword = 86,
|
||||
ElseKeyword = 87,
|
||||
EnumKeyword = 88,
|
||||
ExportKeyword = 89,
|
||||
ExtendsKeyword = 90,
|
||||
FalseKeyword = 91,
|
||||
FinallyKeyword = 92,
|
||||
ForKeyword = 93,
|
||||
FunctionKeyword = 94,
|
||||
IfKeyword = 95,
|
||||
ImportKeyword = 96,
|
||||
InKeyword = 97,
|
||||
InstanceOfKeyword = 98,
|
||||
NewKeyword = 99,
|
||||
NullKeyword = 100,
|
||||
ReturnKeyword = 101,
|
||||
SuperKeyword = 102,
|
||||
SwitchKeyword = 103,
|
||||
ThisKeyword = 104,
|
||||
ThrowKeyword = 105,
|
||||
TrueKeyword = 106,
|
||||
TryKeyword = 107,
|
||||
TypeOfKeyword = 108,
|
||||
VarKeyword = 109,
|
||||
VoidKeyword = 110,
|
||||
WhileKeyword = 111,
|
||||
WithKeyword = 112,
|
||||
ImplementsKeyword = 113,
|
||||
InterfaceKeyword = 114,
|
||||
LetKeyword = 115,
|
||||
PackageKeyword = 116,
|
||||
PrivateKeyword = 117,
|
||||
ProtectedKeyword = 118,
|
||||
PublicKeyword = 119,
|
||||
StaticKeyword = 120,
|
||||
YieldKeyword = 121,
|
||||
AbstractKeyword = 122,
|
||||
AsKeyword = 123,
|
||||
AssertsKeyword = 124,
|
||||
AnyKeyword = 125,
|
||||
AsyncKeyword = 126,
|
||||
AwaitKeyword = 127,
|
||||
BooleanKeyword = 128,
|
||||
ConstructorKeyword = 129,
|
||||
DeclareKeyword = 130,
|
||||
GetKeyword = 131,
|
||||
InferKeyword = 132,
|
||||
IsKeyword = 133,
|
||||
KeyOfKeyword = 134,
|
||||
ModuleKeyword = 135,
|
||||
NamespaceKeyword = 136,
|
||||
NeverKeyword = 137,
|
||||
ReadonlyKeyword = 138,
|
||||
RequireKeyword = 139,
|
||||
NumberKeyword = 140,
|
||||
ObjectKeyword = 141,
|
||||
SetKeyword = 142,
|
||||
StringKeyword = 143,
|
||||
SymbolKeyword = 144,
|
||||
TypeKeyword = 145,
|
||||
UndefinedKeyword = 146,
|
||||
UniqueKeyword = 147,
|
||||
UnknownKeyword = 148,
|
||||
FromKeyword = 149,
|
||||
GlobalKeyword = 150,
|
||||
BigIntKeyword = 151,
|
||||
OfKeyword = 152,
|
||||
QualifiedName = 153,
|
||||
ComputedPropertyName = 154,
|
||||
TypeParameter = 155,
|
||||
Parameter = 156,
|
||||
Decorator = 157,
|
||||
PropertySignature = 158,
|
||||
PropertyDeclaration = 159,
|
||||
MethodSignature = 160,
|
||||
MethodDeclaration = 161,
|
||||
Constructor = 162,
|
||||
GetAccessor = 163,
|
||||
SetAccessor = 164,
|
||||
CallSignature = 165,
|
||||
ConstructSignature = 166,
|
||||
IndexSignature = 167,
|
||||
TypePredicate = 168,
|
||||
TypeReference = 169,
|
||||
FunctionType = 170,
|
||||
ConstructorType = 171,
|
||||
TypeQuery = 172,
|
||||
TypeLiteral = 173,
|
||||
ArrayType = 174,
|
||||
TupleType = 175,
|
||||
OptionalType = 176,
|
||||
RestType = 177,
|
||||
UnionType = 178,
|
||||
IntersectionType = 179,
|
||||
ConditionalType = 180,
|
||||
InferType = 181,
|
||||
ParenthesizedType = 182,
|
||||
ThisType = 183,
|
||||
TypeOperator = 184,
|
||||
IndexedAccessType = 185,
|
||||
MappedType = 186,
|
||||
LiteralType = 187,
|
||||
ImportType = 188,
|
||||
ObjectBindingPattern = 189,
|
||||
ArrayBindingPattern = 190,
|
||||
BindingElement = 191,
|
||||
ArrayLiteralExpression = 192,
|
||||
ObjectLiteralExpression = 193,
|
||||
PropertyAccessExpression = 194,
|
||||
ElementAccessExpression = 195,
|
||||
CallExpression = 196,
|
||||
NewExpression = 197,
|
||||
TaggedTemplateExpression = 198,
|
||||
TypeAssertionExpression = 199,
|
||||
ParenthesizedExpression = 200,
|
||||
FunctionExpression = 201,
|
||||
ArrowFunction = 202,
|
||||
DeleteExpression = 203,
|
||||
TypeOfExpression = 204,
|
||||
VoidExpression = 205,
|
||||
AwaitExpression = 206,
|
||||
PrefixUnaryExpression = 207,
|
||||
PostfixUnaryExpression = 208,
|
||||
BinaryExpression = 209,
|
||||
ConditionalExpression = 210,
|
||||
TemplateExpression = 211,
|
||||
YieldExpression = 212,
|
||||
SpreadElement = 213,
|
||||
ClassExpression = 214,
|
||||
OmittedExpression = 215,
|
||||
ExpressionWithTypeArguments = 216,
|
||||
AsExpression = 217,
|
||||
NonNullExpression = 218,
|
||||
MetaProperty = 219,
|
||||
SyntheticExpression = 220,
|
||||
TemplateSpan = 221,
|
||||
SemicolonClassElement = 222,
|
||||
Block = 223,
|
||||
EmptyStatement = 224,
|
||||
VariableStatement = 225,
|
||||
ExpressionStatement = 226,
|
||||
IfStatement = 227,
|
||||
DoStatement = 228,
|
||||
WhileStatement = 229,
|
||||
ForStatement = 230,
|
||||
ForInStatement = 231,
|
||||
ForOfStatement = 232,
|
||||
ContinueStatement = 233,
|
||||
BreakStatement = 234,
|
||||
ReturnStatement = 235,
|
||||
WithStatement = 236,
|
||||
SwitchStatement = 237,
|
||||
LabeledStatement = 238,
|
||||
ThrowStatement = 239,
|
||||
TryStatement = 240,
|
||||
DebuggerStatement = 241,
|
||||
VariableDeclaration = 242,
|
||||
VariableDeclarationList = 243,
|
||||
FunctionDeclaration = 244,
|
||||
ClassDeclaration = 245,
|
||||
InterfaceDeclaration = 246,
|
||||
TypeAliasDeclaration = 247,
|
||||
EnumDeclaration = 248,
|
||||
ModuleDeclaration = 249,
|
||||
ModuleBlock = 250,
|
||||
CaseBlock = 251,
|
||||
NamespaceExportDeclaration = 252,
|
||||
ImportEqualsDeclaration = 253,
|
||||
ImportDeclaration = 254,
|
||||
ImportClause = 255,
|
||||
NamespaceImport = 256,
|
||||
NamedImports = 257,
|
||||
ImportSpecifier = 258,
|
||||
ExportAssignment = 259,
|
||||
ExportDeclaration = 260,
|
||||
NamedExports = 261,
|
||||
NamespaceExport = 262,
|
||||
ExportSpecifier = 263,
|
||||
MissingDeclaration = 264,
|
||||
ExternalModuleReference = 265,
|
||||
JsxElement = 266,
|
||||
JsxSelfClosingElement = 267,
|
||||
JsxOpeningElement = 268,
|
||||
JsxClosingElement = 269,
|
||||
JsxFragment = 270,
|
||||
JsxOpeningFragment = 271,
|
||||
JsxClosingFragment = 272,
|
||||
JsxAttribute = 273,
|
||||
JsxAttributes = 274,
|
||||
JsxSpreadAttribute = 275,
|
||||
JsxExpression = 276,
|
||||
CaseClause = 277,
|
||||
DefaultClause = 278,
|
||||
HeritageClause = 279,
|
||||
CatchClause = 280,
|
||||
PropertyAssignment = 281,
|
||||
ShorthandPropertyAssignment = 282,
|
||||
SpreadAssignment = 283,
|
||||
EnumMember = 284,
|
||||
UnparsedPrologue = 285,
|
||||
UnparsedPrepend = 286,
|
||||
UnparsedText = 287,
|
||||
UnparsedInternalText = 288,
|
||||
UnparsedSyntheticReference = 289,
|
||||
SourceFile = 290,
|
||||
Bundle = 291,
|
||||
UnparsedSource = 292,
|
||||
InputFiles = 293,
|
||||
JSDocTypeExpression = 294,
|
||||
JSDocAllType = 295,
|
||||
JSDocUnknownType = 296,
|
||||
JSDocNullableType = 297,
|
||||
JSDocNonNullableType = 298,
|
||||
JSDocOptionalType = 299,
|
||||
JSDocFunctionType = 300,
|
||||
JSDocVariadicType = 301,
|
||||
JSDocNamepathType = 302,
|
||||
JSDocComment = 303,
|
||||
JSDocTypeLiteral = 304,
|
||||
JSDocSignature = 305,
|
||||
JSDocTag = 306,
|
||||
JSDocAugmentsTag = 307,
|
||||
JSDocAuthorTag = 308,
|
||||
JSDocClassTag = 309,
|
||||
JSDocPublicTag = 310,
|
||||
JSDocPrivateTag = 311,
|
||||
JSDocProtectedTag = 312,
|
||||
JSDocReadonlyTag = 313,
|
||||
JSDocCallbackTag = 314,
|
||||
JSDocEnumTag = 315,
|
||||
JSDocParameterTag = 316,
|
||||
JSDocReturnTag = 317,
|
||||
JSDocThisTag = 318,
|
||||
JSDocTypeTag = 319,
|
||||
JSDocTemplateTag = 320,
|
||||
JSDocTypedefTag = 321,
|
||||
JSDocPropertyTag = 322,
|
||||
SyntaxList = 323,
|
||||
NotEmittedStatement = 324,
|
||||
PartiallyEmittedExpression = 325,
|
||||
CommaListExpression = 326,
|
||||
MergeDeclarationMarker = 327,
|
||||
EndOfDeclarationMarker = 328,
|
||||
SyntheticReferenceExpression = 329,
|
||||
Count = 330,
|
||||
FirstAssignment = 62,
|
||||
LastAssignment = 74,
|
||||
FirstCompoundAssignment = 63,
|
||||
LastCompoundAssignment = 74,
|
||||
FirstReservedWord = 76,
|
||||
LastReservedWord = 111,
|
||||
FirstKeyword = 76,
|
||||
LastKeyword = 151,
|
||||
FirstFutureReservedWord = 112,
|
||||
LastFutureReservedWord = 120,
|
||||
FirstTypeNode = 167,
|
||||
LastTypeNode = 187,
|
||||
FirstReservedWord = 77,
|
||||
LastReservedWord = 112,
|
||||
FirstKeyword = 77,
|
||||
LastKeyword = 152,
|
||||
FirstFutureReservedWord = 113,
|
||||
LastFutureReservedWord = 121,
|
||||
FirstTypeNode = 168,
|
||||
LastTypeNode = 188,
|
||||
FirstPunctuation = 18,
|
||||
LastPunctuation = 74,
|
||||
FirstToken = 0,
|
||||
LastToken = 151,
|
||||
LastToken = 152,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -429,13 +430,13 @@ declare namespace ts {
|
||||
LastTemplateToken = 17,
|
||||
FirstBinaryOperator = 29,
|
||||
LastBinaryOperator = 74,
|
||||
FirstStatement = 224,
|
||||
LastStatement = 240,
|
||||
FirstNode = 152,
|
||||
FirstJSDocNode = 293,
|
||||
LastJSDocNode = 321,
|
||||
FirstJSDocTagNode = 305,
|
||||
LastJSDocTagNode = 321,
|
||||
FirstStatement = 225,
|
||||
LastStatement = 241,
|
||||
FirstNode = 153,
|
||||
FirstJSDocNode = 294,
|
||||
LastJSDocNode = 322,
|
||||
FirstJSDocTagNode = 306,
|
||||
LastJSDocTagNode = 322,
|
||||
}
|
||||
export enum NodeFlags {
|
||||
None = 0,
|
||||
@@ -552,8 +553,8 @@ declare namespace ts {
|
||||
right: Identifier;
|
||||
}
|
||||
export type EntityName = Identifier | QualifiedName;
|
||||
export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName;
|
||||
export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression;
|
||||
export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier;
|
||||
export type DeclarationName = Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression;
|
||||
export interface Declaration extends Node {
|
||||
_declarationBrand: any;
|
||||
}
|
||||
@@ -568,6 +569,10 @@ declare namespace ts {
|
||||
kind: SyntaxKind.ComputedPropertyName;
|
||||
expression: Expression;
|
||||
}
|
||||
export interface PrivateIdentifier extends Node {
|
||||
kind: SyntaxKind.PrivateIdentifier;
|
||||
escapedText: __String;
|
||||
}
|
||||
export interface Decorator extends Node {
|
||||
kind: SyntaxKind.Decorator;
|
||||
parent: NamedDeclaration;
|
||||
@@ -1093,10 +1098,11 @@ declare namespace ts {
|
||||
kind: SyntaxKind.PropertyAccessExpression;
|
||||
expression: LeftHandSideExpression;
|
||||
questionDotToken?: QuestionDotToken;
|
||||
name: Identifier;
|
||||
name: Identifier | PrivateIdentifier;
|
||||
}
|
||||
export interface PropertyAccessChain extends PropertyAccessExpression {
|
||||
_optionalChainBrand: any;
|
||||
name: Identifier;
|
||||
}
|
||||
export interface SuperPropertyAccessExpression extends PropertyAccessExpression {
|
||||
expression: SuperExpression;
|
||||
@@ -1105,6 +1111,7 @@ declare namespace ts {
|
||||
export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression {
|
||||
_propertyAccessExpressionLikeQualifiedNameBrand?: any;
|
||||
expression: EntityNameExpression;
|
||||
name: Identifier;
|
||||
}
|
||||
export interface ElementAccessExpression extends MemberExpression {
|
||||
kind: SyntaxKind.ElementAccessExpression;
|
||||
@@ -2002,6 +2009,7 @@ declare namespace ts {
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
|
||||
getPrivateIdentifierPropertyOfType(leftType: Type, name: string, location: Node): Symbol | undefined;
|
||||
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined;
|
||||
getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[];
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined;
|
||||
@@ -3440,9 +3448,9 @@ declare namespace ts {
|
||||
* @returns The unescaped identifier text.
|
||||
*/
|
||||
function unescapeLeadingUnderscores(identifier: __String): string;
|
||||
function idText(identifier: Identifier): string;
|
||||
function idText(identifierOrPrivateName: Identifier | PrivateIdentifier): string;
|
||||
function symbolName(symbol: Symbol): string;
|
||||
function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined;
|
||||
function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined;
|
||||
function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined;
|
||||
/**
|
||||
* Gets the JSDoc parameter tags for the node if present.
|
||||
@@ -3538,6 +3546,8 @@ declare namespace ts {
|
||||
function isIdentifier(node: Node): node is Identifier;
|
||||
function isQualifiedName(node: Node): node is QualifiedName;
|
||||
function isComputedPropertyName(node: Node): node is ComputedPropertyName;
|
||||
function isPrivateIdentifier(node: Node): node is PrivateIdentifier;
|
||||
function isIdentifierOrPrivateIdentifier(node: Node): node is Identifier | PrivateIdentifier;
|
||||
function isTypeParameterDeclaration(node: Node): node is TypeParameterDeclaration;
|
||||
function isParameter(node: Node): node is ParameterDeclaration;
|
||||
function isDecorator(node: Node): node is Decorator;
|
||||
@@ -3937,6 +3947,7 @@ declare namespace ts {
|
||||
function createFileLevelUniqueName(text: string): Identifier;
|
||||
/** Create a unique name generated for a node. */
|
||||
function getGeneratedNameForNode(node: Node | undefined): Identifier;
|
||||
function createPrivateIdentifier(text: string): PrivateIdentifier;
|
||||
function createToken<TKind extends SyntaxKind>(token: TKind): Token<TKind>;
|
||||
function createSuper(): SuperExpression;
|
||||
function createThis(): ThisExpression & Token<SyntaxKind.ThisKeyword>;
|
||||
@@ -4031,8 +4042,8 @@ declare namespace ts {
|
||||
function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression;
|
||||
function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression;
|
||||
function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression;
|
||||
function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression;
|
||||
function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression;
|
||||
function createPropertyAccess(expression: Expression, name: string | Identifier | PrivateIdentifier): PropertyAccessExpression;
|
||||
function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier): PropertyAccessExpression;
|
||||
function createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier): PropertyAccessChain;
|
||||
function updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier): PropertyAccessChain;
|
||||
function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression;
|
||||
@@ -4942,6 +4953,9 @@ declare namespace ts {
|
||||
interface Identifier {
|
||||
readonly text: string;
|
||||
}
|
||||
interface PrivateIdentifier {
|
||||
readonly text: string;
|
||||
}
|
||||
interface Symbol {
|
||||
readonly name: string;
|
||||
getFlags(): SymbolFlags;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(6,12): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(10,12): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(6,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(10,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts (2 errors) ====
|
||||
@@ -10,13 +10,13 @@ tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(10,12): e
|
||||
async function bar1() {
|
||||
delete await 42; // OK
|
||||
~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
}
|
||||
|
||||
async function bar2() {
|
||||
delete await 42; // OK
|
||||
~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
}
|
||||
|
||||
async function bar3() {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(2,12): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(6,12): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(2,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(6,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts (2 errors) ====
|
||||
async function bar1() {
|
||||
delete await 42;
|
||||
~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
}
|
||||
|
||||
async function bar2() {
|
||||
delete await 42;
|
||||
~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
}
|
||||
|
||||
async function bar3() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(6,12): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(10,12): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(6,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(10,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts (2 errors) ====
|
||||
@@ -10,13 +10,13 @@ tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(10,12): error T
|
||||
async function bar1() {
|
||||
delete await 42; // OK
|
||||
~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
}
|
||||
|
||||
async function bar2() {
|
||||
delete await 42; // OK
|
||||
~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
}
|
||||
|
||||
async function bar3() {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(2,12): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(6,12): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(2,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(6,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts (2 errors) ====
|
||||
async function bar1() {
|
||||
delete await 42;
|
||||
~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
}
|
||||
|
||||
async function bar2() {
|
||||
delete await 42;
|
||||
~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
}
|
||||
|
||||
async function bar3() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/compiler/classUpdateTests.ts(34,2): error TS2377: Constructors for derived classes must contain a 'super' call.
|
||||
tests/cases/compiler/classUpdateTests.ts(43,18): error TS2335: 'super' can only be referenced in a derived class.
|
||||
tests/cases/compiler/classUpdateTests.ts(57,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
tests/cases/compiler/classUpdateTests.ts(57,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
tests/cases/compiler/classUpdateTests.ts(63,7): error TS2415: Class 'L' incorrectly extends base class 'G'.
|
||||
Property 'p1' is private in type 'L' but not in type 'G'.
|
||||
tests/cases/compiler/classUpdateTests.ts(69,7): error TS2415: Class 'M' incorrectly extends base class 'G'.
|
||||
Property 'p1' is private in type 'M' but not in type 'G'.
|
||||
tests/cases/compiler/classUpdateTests.ts(70,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
tests/cases/compiler/classUpdateTests.ts(70,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
tests/cases/compiler/classUpdateTests.ts(93,3): error TS1128: Declaration or statement expected.
|
||||
tests/cases/compiler/classUpdateTests.ts(95,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/compiler/classUpdateTests.ts(99,3): error TS1128: Declaration or statement expected.
|
||||
@@ -87,7 +87,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st
|
||||
~~~~~~~~~~
|
||||
}
|
||||
~~
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
}
|
||||
|
||||
class L extends G {
|
||||
@@ -111,7 +111,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st
|
||||
~~~~~~~~~~
|
||||
}
|
||||
~~
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -2,7 +2,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(4,1
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,9): error TS2378: A 'get' accessor must return a value.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,17): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,17): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,16): error TS2378: A 'get' accessor must return a value.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
@@ -23,7 +23,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,1
|
||||
~~
|
||||
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
set [[0, 1]](v) { }
|
||||
~~~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
@@ -2,7 +2,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(4,1
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2378: A 'get' accessor must return a value.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2378: A 'get' accessor must return a value.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
@@ -23,7 +23,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,1
|
||||
~~
|
||||
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
set [[0, 1]](v) { }
|
||||
~~~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (1 errors) ====
|
||||
@@ -17,6 +17,6 @@ tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error T
|
||||
x;
|
||||
delete x; // No effect
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
x;
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
tests/cases/compiler/deleteOperator1.ts(2,25): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/compiler/deleteOperator1.ts(3,21): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/compiler/deleteOperator1.ts(2,25): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/compiler/deleteOperator1.ts(3,21): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/compiler/deleteOperator1.ts(4,5): error TS2322: Type 'boolean' is not assignable to type 'number'.
|
||||
tests/cases/compiler/deleteOperator1.ts(4,24): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/compiler/deleteOperator1.ts(4,24): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/compiler/deleteOperator1.ts (4 errors) ====
|
||||
var a;
|
||||
var x: boolean = delete a;
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var y: any = delete a;
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var z: number = delete a;
|
||||
~
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/deleteOperatorInStrictMode.ts(3,8): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/compiler/deleteOperatorInStrictMode.ts(3,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/compiler/deleteOperatorInStrictMode.ts(3,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/compiler/deleteOperatorInStrictMode.ts (2 errors) ====
|
||||
@@ -9,4 +9,4 @@ tests/cases/compiler/deleteOperatorInStrictMode.ts(3,8): error TS2703: The opera
|
||||
~
|
||||
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,20): error TS1005: ',' expected.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,26): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,26): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,27): error TS1109: Expression expected.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(8,22): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(8,22): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(8,23): error TS1109: Expression expected.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(13,16): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(13,16): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(13,16): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts (7 errors) ====
|
||||
@@ -16,14 +16,14 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
~~~~~~
|
||||
!!! error TS1005: ',' expected.
|
||||
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
|
||||
// miss an operand
|
||||
var BOOLEAN2 = delete ;
|
||||
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
|
||||
@@ -34,6 +34,6 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
~
|
||||
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,28 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(25,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(26,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(27,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(28,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(29,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(30,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(33,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(34,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(42,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(43,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(44,33): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(25,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(26,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(27,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(28,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(29,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(30,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(33,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(34,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(42,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(43,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(44,33): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,39): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,39): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,47): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(54,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(55,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(57,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,39): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,39): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,47): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(54,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(55,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(57,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (25 errors) ====
|
||||
@@ -52,30 +52,30 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
// any type var
|
||||
var ResultIsBoolean1 = delete ANY1;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean2 = delete ANY2;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean3 = delete A;
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean4 = delete M;
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean5 = delete obj;
|
||||
~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean6 = delete obj1;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// any type literal
|
||||
var ResultIsBoolean7 = delete undefined;
|
||||
~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean8 = delete null;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// any type expressions
|
||||
var ResultIsBoolean9 = delete ANY2[0];
|
||||
@@ -85,54 +85,54 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
var ResultIsBoolean13 = delete M.n;
|
||||
var ResultIsBoolean14 = delete foo();
|
||||
~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean15 = delete A.foo();
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean16 = delete (ANY + ANY1);
|
||||
~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean17 = delete (null + undefined);
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean18 = delete (null + null);
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean19 = delete (undefined + undefined);
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// multiple delete operators
|
||||
var ResultIsBoolean20 = delete delete ANY;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean21 = delete delete delete (ANY + ANY1);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// miss assignment operators
|
||||
delete ANY;
|
||||
~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete ANY1;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete ANY2[0];
|
||||
delete ANY, ANY1;
|
||||
~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete obj1.x;
|
||||
delete obj1.y;
|
||||
delete objA.a;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(17,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(20,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(21,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(26,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(27,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(30,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(30,38): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(33,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(34,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(35,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(36,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(17,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(20,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(21,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(26,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(27,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(30,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(30,38): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(33,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(34,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(35,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(36,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts (11 errors) ====
|
||||
@@ -30,45 +30,45 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
// boolean type var
|
||||
var ResultIsBoolean1 = delete BOOLEAN;
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// boolean type literal
|
||||
var ResultIsBoolean2 = delete true;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean3 = delete { x: true, y: false };
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// boolean type expressions
|
||||
var ResultIsBoolean4 = delete objA.a;
|
||||
var ResultIsBoolean5 = delete M.n;
|
||||
var ResultIsBoolean6 = delete foo();
|
||||
~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean7 = delete A.foo();
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// multiple delete operator
|
||||
var ResultIsBoolean8 = delete delete BOOLEAN;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// miss assignment operators
|
||||
delete true;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete BOOLEAN;
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete foo();
|
||||
~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete true, false;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete objA.a;
|
||||
delete M.n;
|
||||
@@ -1,16 +1,16 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(7,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(8,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(11,31): error TS2704: The operand of a delete operator cannot be a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(12,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,38): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,38): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,46): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(19,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(20,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(21,8): error TS2704: The operand of a delete operator cannot be a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(22,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(7,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(8,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(11,31): error TS2704: The operand of a 'delete' operator cannot be a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(12,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,38): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,38): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,46): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(19,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(20,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(21,8): error TS2704: The operand of a 'delete' operator cannot be a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(22,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts (13 errors) ====
|
||||
@@ -22,43 +22,43 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
// enum type var
|
||||
var ResultIsBoolean1 = delete ENUM;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean2 = delete ENUM1;
|
||||
~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// enum type expressions
|
||||
var ResultIsBoolean3 = delete ENUM1["A"];
|
||||
~~~~~~~~~~
|
||||
!!! error TS2704: The operand of a delete operator cannot be a read-only property.
|
||||
!!! error TS2704: The operand of a 'delete' operator cannot be a read-only property.
|
||||
var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]);
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// multiple delete operators
|
||||
var ResultIsBoolean5 = delete delete ENUM;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean6 = delete delete delete (ENUM[0] + ENUM1["B"]);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// miss assignment operators
|
||||
delete ENUM;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete ENUM1;
|
||||
~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete ENUM1.B;
|
||||
~~~~~~~
|
||||
!!! error TS2704: The operand of a delete operator cannot be a read-only property.
|
||||
!!! error TS2704: The operand of a 'delete' operator cannot be a read-only property.
|
||||
delete ENUM, ENUM1;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
@@ -1,20 +1,20 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(18,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(19,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(22,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(23,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(24,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(30,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(31,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(32,33): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(35,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(35,39): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,39): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,47): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(39,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(40,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(41,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(42,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(18,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(19,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(22,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(23,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(24,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(30,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(31,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(32,33): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(35,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(35,39): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,39): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,47): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(39,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(40,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(41,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(42,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts (17 errors) ====
|
||||
@@ -37,21 +37,21 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
// number type var
|
||||
var ResultIsBoolean1 = delete NUMBER;
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean2 = delete NUMBER1;
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// number type literal
|
||||
var ResultIsBoolean3 = delete 1;
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean4 = delete { x: 1, y: 2};
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean5 = delete { x: 1, y: (n: number) => { return n; } };
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// number type expressions
|
||||
var ResultIsBoolean6 = delete objA.a;
|
||||
@@ -59,41 +59,41 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
var ResultIsBoolean8 = delete NUMBER1[0];
|
||||
var ResultIsBoolean9 = delete foo();
|
||||
~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean10 = delete A.foo();
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean11 = delete (NUMBER + NUMBER);
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// multiple delete operator
|
||||
var ResultIsBoolean12 = delete delete NUMBER;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean13 = delete delete delete (NUMBER + NUMBER);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// miss assignment operators
|
||||
delete 1;
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete NUMBER;
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete NUMBER1;
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete foo();
|
||||
~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete objA.a;
|
||||
delete M.n;
|
||||
delete objA.a, M.n;
|
||||
@@ -1,21 +1,21 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(18,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(19,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(22,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(23,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(24,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(30,31): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(31,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(32,33): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(33,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(36,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(36,39): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,32): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,39): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,47): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(40,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(41,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(42,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(43,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(18,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(19,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(22,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(23,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(24,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(30,31): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(31,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(32,33): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(33,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(36,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(36,39): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,32): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,39): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,47): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(40,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(41,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(42,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(43,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts (18 errors) ====
|
||||
@@ -38,21 +38,21 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
// string type var
|
||||
var ResultIsBoolean1 = delete STRING;
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean2 = delete STRING1;
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// string type literal
|
||||
var ResultIsBoolean3 = delete "";
|
||||
~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean4 = delete { x: "", y: "" };
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean5 = delete { x: "", y: (s: string) => { return s; } };
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// string type expressions
|
||||
var ResultIsBoolean6 = delete objA.a;
|
||||
@@ -60,42 +60,42 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
|
||||
var ResultIsBoolean8 = delete STRING1[0];
|
||||
var ResultIsBoolean9 = delete foo();
|
||||
~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean10 = delete A.foo();
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean11 = delete (STRING + STRING);
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean12 = delete STRING.charAt(0);
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// multiple delete operator
|
||||
var ResultIsBoolean13 = delete delete STRING;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
var ResultIsBoolean14 = delete delete delete (STRING + STRING);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
// miss assignment operators
|
||||
delete "";
|
||||
~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete STRING;
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete STRING1;
|
||||
~~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete foo();
|
||||
~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete objA.a,M.n;
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/deleteReadonly.ts(8,8): error TS2704: The operand of a delete operator cannot be a read-only property.
|
||||
tests/cases/compiler/deleteReadonly.ts(8,8): error TS2704: The operand of a 'delete' operator cannot be a read-only property.
|
||||
tests/cases/compiler/deleteReadonly.ts(18,8): error TS2542: Index signature in type 'B' only permits reading.
|
||||
tests/cases/compiler/deleteReadonly.ts(20,12): error TS2542: Index signature in type 'B' only permits reading.
|
||||
|
||||
@@ -13,7 +13,7 @@ tests/cases/compiler/deleteReadonly.ts(20,12): error TS2542: Index signature in
|
||||
|
||||
delete a.b;
|
||||
~~~
|
||||
!!! error TS2704: The operand of a delete operator cannot be a read-only property.
|
||||
!!! error TS2704: The operand of a 'delete' operator cannot be a read-only property.
|
||||
|
||||
interface B {
|
||||
readonly [k: string]: string
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(15,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(30,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(15,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(30,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(47,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(56,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(56,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(57,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(58,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(79,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(79,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(80,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(81,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
|
||||
@@ -32,7 +32,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
}
|
||||
|
||||
class Derived3 extends Base {
|
||||
@@ -52,7 +52,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
}
|
||||
|
||||
class Derived5 extends Base {
|
||||
@@ -91,7 +91,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
}
|
||||
|
||||
class Derived8 extends Base {
|
||||
@@ -124,7 +124,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
|
||||
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
|
||||
}
|
||||
|
||||
class Derived10<T> extends Base2<T> {
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(4,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(4,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(4,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(4,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(10,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(10,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(10,13): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(10,13): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,13): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,13): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,13): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,13): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,13): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,13): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(15,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(15,1): error TS17006: An unary expression with the 'typeof' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(16,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
@@ -109,28 +109,28 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete ++temp ** 3;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete temp-- ** 3;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete temp++ ** 3;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
1 ** delete --temp ** 3;
|
||||
@@ -139,28 +139,28 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
1 ** delete ++temp ** 3;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
1 ** delete temp-- ** 3;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
1 ** delete temp++ ** 3;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
typeof --temp ** 3;
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
+16
-16
@@ -19,21 +19,21 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInv
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(25,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(26,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(28,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(28,9): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(28,9): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(29,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(29,9): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(29,9): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(30,9): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(30,9): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(31,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(31,9): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(31,9): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(33,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(33,14): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(33,14): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(34,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(34,14): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(34,14): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(35,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(35,14): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(35,14): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(36,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(36,14): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(36,14): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts (36 errors) ====
|
||||
@@ -108,40 +108,40 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInv
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
(delete ++temp) ** 3;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
(delete temp--) ** 3;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
(delete temp++) ** 3;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
1 ** (delete --temp) ** 3;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
1 ** (delete ++temp) ** 3;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
1 ** (delete temp--) ** 3;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
1 ** (delete temp++) ** 3;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
@@ -0,0 +1,30 @@
|
||||
//// [file.js]
|
||||
export class C {
|
||||
#hello = "hello";
|
||||
#world = 100;
|
||||
|
||||
#calcHello() {
|
||||
return this.#hello;
|
||||
}
|
||||
|
||||
get #screamingHello() {
|
||||
return this.#hello.toUpperCase();
|
||||
}
|
||||
/** @param value {string} */
|
||||
set #screamingHello(value) {
|
||||
throw "NO";
|
||||
}
|
||||
|
||||
getWorld() {
|
||||
return this.#world;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//// [file.d.ts]
|
||||
export class C {
|
||||
getWorld(): number;
|
||||
#private;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
=== tests/cases/conformance/jsdoc/declarations/file.js ===
|
||||
export class C {
|
||||
>C : Symbol(C, Decl(file.js, 0, 0))
|
||||
|
||||
#hello = "hello";
|
||||
>#hello : Symbol(C.#hello, Decl(file.js, 0, 16))
|
||||
|
||||
#world = 100;
|
||||
>#world : Symbol(C.#world, Decl(file.js, 1, 21))
|
||||
|
||||
#calcHello() {
|
||||
>#calcHello : Symbol(C.#calcHello, Decl(file.js, 2, 17))
|
||||
|
||||
return this.#hello;
|
||||
>this.#hello : Symbol(C.#hello, Decl(file.js, 0, 16))
|
||||
>this : Symbol(C, Decl(file.js, 0, 0))
|
||||
}
|
||||
|
||||
get #screamingHello() {
|
||||
>#screamingHello : Symbol(C.#screamingHello, Decl(file.js, 6, 5), Decl(file.js, 10, 5))
|
||||
|
||||
return this.#hello.toUpperCase();
|
||||
>this.#hello.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
|
||||
>this.#hello : Symbol(C.#hello, Decl(file.js, 0, 16))
|
||||
>this : Symbol(C, Decl(file.js, 0, 0))
|
||||
>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
/** @param value {string} */
|
||||
set #screamingHello(value) {
|
||||
>#screamingHello : Symbol(C.#screamingHello, Decl(file.js, 6, 5), Decl(file.js, 10, 5))
|
||||
>value : Symbol(value, Decl(file.js, 12, 24))
|
||||
|
||||
throw "NO";
|
||||
}
|
||||
|
||||
getWorld() {
|
||||
>getWorld : Symbol(C.getWorld, Decl(file.js, 14, 5))
|
||||
|
||||
return this.#world;
|
||||
>this.#world : Symbol(C.#world, Decl(file.js, 1, 21))
|
||||
>this : Symbol(C, Decl(file.js, 0, 0))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
=== tests/cases/conformance/jsdoc/declarations/file.js ===
|
||||
export class C {
|
||||
>C : C
|
||||
|
||||
#hello = "hello";
|
||||
>#hello : string
|
||||
>"hello" : "hello"
|
||||
|
||||
#world = 100;
|
||||
>#world : number
|
||||
>100 : 100
|
||||
|
||||
#calcHello() {
|
||||
>#calcHello : () => string
|
||||
|
||||
return this.#hello;
|
||||
>this.#hello : string
|
||||
>this : this
|
||||
}
|
||||
|
||||
get #screamingHello() {
|
||||
>#screamingHello : string
|
||||
|
||||
return this.#hello.toUpperCase();
|
||||
>this.#hello.toUpperCase() : string
|
||||
>this.#hello.toUpperCase : () => string
|
||||
>this.#hello : string
|
||||
>this : this
|
||||
>toUpperCase : () => string
|
||||
}
|
||||
/** @param value {string} */
|
||||
set #screamingHello(value) {
|
||||
>#screamingHello : string
|
||||
>value : string
|
||||
|
||||
throw "NO";
|
||||
>"NO" : "NO"
|
||||
}
|
||||
|
||||
getWorld() {
|
||||
>getWorld : () => number
|
||||
|
||||
return this.#world;
|
||||
>this.#world : number
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ tests/cases/compiler/a.js(5,5): error TS1117: An object literal cannot have mult
|
||||
tests/cases/compiler/a.js(5,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/a.js(7,5): error TS1212: Identifier expected. 'let' is a reserved word in strict mode.
|
||||
tests/cases/compiler/a.js(8,8): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/compiler/a.js(8,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/compiler/a.js(8,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/compiler/a.js(10,10): error TS1100: Invalid use of 'eval' in strict mode.
|
||||
tests/cases/compiler/a.js(12,10): error TS1100: Invalid use of 'arguments' in strict mode.
|
||||
tests/cases/compiler/a.js(15,1): error TS1101: 'with' statements are not allowed in strict mode.
|
||||
@@ -33,7 +33,7 @@ tests/cases/compiler/d.js(2,11): error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
try {
|
||||
} catch (eval) { // error
|
||||
~~~~
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
tests/cases/conformance/jsdoc/jsdocPrivateName1.js(3,5): error TS2322: Type '3' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsdoc/jsdocPrivateName1.js (1 errors) ====
|
||||
class A {
|
||||
/** @type {boolean} some number value */
|
||||
#foo = 3 // Error because not assignable to boolean
|
||||
~~~~
|
||||
!!! error TS2322: Type '3' is not assignable to type 'boolean'.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/jsdoc/jsdocPrivateName1.js ===
|
||||
class A {
|
||||
>A : Symbol(A, Decl(jsdocPrivateName1.js, 0, 0))
|
||||
|
||||
/** @type {boolean} some number value */
|
||||
#foo = 3 // Error because not assignable to boolean
|
||||
>#foo : Symbol(A.#foo, Decl(jsdocPrivateName1.js, 0, 9))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/jsdoc/jsdocPrivateName1.js ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
/** @type {boolean} some number value */
|
||||
#foo = 3 // Error because not assignable to boolean
|
||||
>#foo : boolean
|
||||
>3 : 3
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/jsdoc/jsdocPrivateName1.js(6,23): error TS1003: Identifier expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsdoc/jsdocPrivateName1.js (1 errors) ====
|
||||
// Expecting parse error for private field
|
||||
|
||||
/**
|
||||
* @typedef A
|
||||
* @type {object}
|
||||
* @property {string} #id
|
||||
|
||||
!!! error TS1003: Identifier expected.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/jsdoc/jsdocPrivateName1.js ===
|
||||
// Expecting parse error for private field
|
||||
No type information for this code.
|
||||
No type information for this code./**
|
||||
No type information for this code. * @typedef A
|
||||
No type information for this code. * @type {object}
|
||||
No type information for this code. * @property {string} #id
|
||||
No type information for this code. */
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/jsdoc/jsdocPrivateName1.js ===
|
||||
// Expecting parse error for private field
|
||||
No type information for this code.
|
||||
No type information for this code./**
|
||||
No type information for this code. * @typedef A
|
||||
No type information for this code. * @type {object}
|
||||
No type information for this code. * @property {string} #id
|
||||
No type information for this code. */
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
@@ -3,7 +3,7 @@ tests/cases/compiler/parseErrorInHeritageClause1.ts(1,19): error TS1127: Invalid
|
||||
|
||||
|
||||
==== tests/cases/compiler/parseErrorInHeritageClause1.ts (2 errors) ====
|
||||
class C extends A # {
|
||||
class C extends A ¬ {
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//// [parseErrorInHeritageClause1.ts]
|
||||
class C extends A # {
|
||||
class C extends A ¬ {
|
||||
}
|
||||
|
||||
//// [parseErrorInHeritageClause1.js]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/compiler/parseErrorInHeritageClause1.ts ===
|
||||
class C extends A # {
|
||||
class C extends A ¬ {
|
||||
>C : Symbol(C, Decl(parseErrorInHeritageClause1.ts, 0, 0))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/compiler/parseErrorInHeritageClause1.ts ===
|
||||
class C extends A # {
|
||||
class C extends A ¬ {
|
||||
>C : C
|
||||
>A : any
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecov
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block2.ts (1 errors) ====
|
||||
function f() {
|
||||
#
|
||||
¬
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [parserErrorRecovery_Block2.ts]
|
||||
function f() {
|
||||
#
|
||||
¬
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
function f() {
|
||||
>f : Symbol(f, Decl(parserErrorRecovery_Block2.ts, 0, 0))
|
||||
|
||||
#
|
||||
¬
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
function f() {
|
||||
>f : () => void
|
||||
|
||||
#
|
||||
¬
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ClassElements/parserErr
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ClassElements/parserErrorRecovery_ClassElement3.ts (4 errors) ====
|
||||
module M {
|
||||
#
|
||||
¬
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
class C {
|
||||
@@ -15,7 +15,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ClassElements/parserErr
|
||||
enum E {
|
||||
~~~~
|
||||
!!! error TS1109: Expression expected.
|
||||
#
|
||||
¬
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//// [parserErrorRecovery_ClassElement3.ts]
|
||||
module M {
|
||||
#
|
||||
¬
|
||||
class C {
|
||||
}
|
||||
@
|
||||
enum E {
|
||||
#
|
||||
¬
|
||||
|
||||
//// [parserErrorRecovery_ClassElement3.js]
|
||||
var M;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
module M {
|
||||
>M : Symbol(M, Decl(parserErrorRecovery_ClassElement3.ts, 0, 0))
|
||||
|
||||
#
|
||||
¬
|
||||
class C {
|
||||
>C : Symbol(C, Decl(parserErrorRecovery_ClassElement3.ts, 1, 4))
|
||||
}
|
||||
@@ -10,4 +10,4 @@ module M {
|
||||
enum E {
|
||||
>E : Symbol(E, Decl(parserErrorRecovery_ClassElement3.ts, 3, 4))
|
||||
|
||||
#
|
||||
¬
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
module M {
|
||||
>M : typeof M
|
||||
|
||||
#
|
||||
¬
|
||||
class C {
|
||||
>C : C
|
||||
}
|
||||
@@ -11,4 +11,4 @@ module M {
|
||||
> : any
|
||||
>E : E
|
||||
|
||||
#
|
||||
¬
|
||||
|
||||
@@ -2,7 +2,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserEr
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList4.ts (1 errors) ====
|
||||
function f(a,#) {
|
||||
function f(a,¬) {
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//// [parserErrorRecovery_ParameterList4.ts]
|
||||
function f(a,#) {
|
||||
function f(a,¬) {
|
||||
}
|
||||
|
||||
//// [parserErrorRecovery_ParameterList4.js]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList4.ts ===
|
||||
function f(a,#) {
|
||||
function f(a,¬) {
|
||||
>f : Symbol(f, Decl(parserErrorRecovery_ParameterList4.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(parserErrorRecovery_ParameterList4.ts, 0, 11))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList4.ts ===
|
||||
function f(a,#) {
|
||||
function f(a,¬) {
|
||||
>f : (a: any) => void
|
||||
>a : any
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.t
|
||||
!!! error TS2304: Cannot find name 'Bar'.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
function Foo () # { }
|
||||
function Foo () ¬ { }
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
4+:5
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [parserSkippedTokens16.ts]
|
||||
foo(): Bar { }
|
||||
function Foo () # { }
|
||||
function Foo () ¬ { }
|
||||
4+:5
|
||||
module M {
|
||||
function a(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts ===
|
||||
foo(): Bar { }
|
||||
function Foo () # { }
|
||||
function Foo () ¬ { }
|
||||
>Foo : Symbol(Foo, Decl(parserSkippedTokens16.ts, 0, 14))
|
||||
|
||||
4+:5
|
||||
|
||||
@@ -4,7 +4,7 @@ foo(): Bar { }
|
||||
>foo : any
|
||||
>Bar : any
|
||||
|
||||
function Foo () # { }
|
||||
function Foo () ¬ { }
|
||||
>Foo : () => any
|
||||
|
||||
4+:5
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts (3 errors) ====
|
||||
@@ -11,4 +11,4 @@ tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8)
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
@@ -1,20 +1,20 @@
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(2,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(3,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(4,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(5,8): error TS2703: The operand of a delete operator must be a property reference.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(2,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(3,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(4,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(5,8): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts (4 errors) ====
|
||||
"use strict";
|
||||
delete this;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete 1;
|
||||
~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete null;
|
||||
~~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
delete "a";
|
||||
~~~
|
||||
!!! error TS2703: The operand of a delete operator must be a property reference.
|
||||
!!! error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
@@ -0,0 +1,28 @@
|
||||
tests/cases/conformance/expressions/optionalChaining/privateIdentifierChain/privateIdentifierChain.1.ts(8,15): error TS18030: An optional chain cannot contain private identifiers.
|
||||
tests/cases/conformance/expressions/optionalChaining/privateIdentifierChain/privateIdentifierChain.1.ts(9,9): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/conformance/expressions/optionalChaining/privateIdentifierChain/privateIdentifierChain.1.ts(9,17): error TS18030: An optional chain cannot contain private identifiers.
|
||||
tests/cases/conformance/expressions/optionalChaining/privateIdentifierChain/privateIdentifierChain.1.ts(10,22): error TS18030: An optional chain cannot contain private identifiers.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/optionalChaining/privateIdentifierChain/privateIdentifierChain.1.ts (4 errors) ====
|
||||
class A {
|
||||
a?: A
|
||||
#b?: A;
|
||||
getA(): A {
|
||||
return new A();
|
||||
}
|
||||
constructor() {
|
||||
this?.#b; // Error
|
||||
~~
|
||||
!!! error TS18030: An optional chain cannot contain private identifiers.
|
||||
this?.a.#b; // Error
|
||||
~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~~
|
||||
!!! error TS18030: An optional chain cannot contain private identifiers.
|
||||
this?.getA().#b; // Error
|
||||
~~
|
||||
!!! error TS18030: An optional chain cannot contain private identifiers.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [privateIdentifierChain.1.ts]
|
||||
class A {
|
||||
a?: A
|
||||
#b?: A;
|
||||
getA(): A {
|
||||
return new A();
|
||||
}
|
||||
constructor() {
|
||||
this?.#b; // Error
|
||||
this?.a.#b; // Error
|
||||
this?.getA().#b; // Error
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [privateIdentifierChain.1.js]
|
||||
"use strict";
|
||||
class A {
|
||||
constructor() {
|
||||
this?.#b; // Error
|
||||
this?.a.#b; // Error
|
||||
this?.getA().#b; // Error
|
||||
}
|
||||
#b;
|
||||
getA() {
|
||||
return new A();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/expressions/optionalChaining/privateIdentifierChain/privateIdentifierChain.1.ts ===
|
||||
class A {
|
||||
>A : Symbol(A, Decl(privateIdentifierChain.1.ts, 0, 0))
|
||||
|
||||
a?: A
|
||||
>a : Symbol(A.a, Decl(privateIdentifierChain.1.ts, 0, 9))
|
||||
>A : Symbol(A, Decl(privateIdentifierChain.1.ts, 0, 0))
|
||||
|
||||
#b?: A;
|
||||
>#b : Symbol(A.#b, Decl(privateIdentifierChain.1.ts, 1, 9))
|
||||
>A : Symbol(A, Decl(privateIdentifierChain.1.ts, 0, 0))
|
||||
|
||||
getA(): A {
|
||||
>getA : Symbol(A.getA, Decl(privateIdentifierChain.1.ts, 2, 11))
|
||||
>A : Symbol(A, Decl(privateIdentifierChain.1.ts, 0, 0))
|
||||
|
||||
return new A();
|
||||
>A : Symbol(A, Decl(privateIdentifierChain.1.ts, 0, 0))
|
||||
}
|
||||
constructor() {
|
||||
this?.#b; // Error
|
||||
>this : Symbol(A, Decl(privateIdentifierChain.1.ts, 0, 0))
|
||||
|
||||
this?.a.#b; // Error
|
||||
>this?.a : Symbol(A.a, Decl(privateIdentifierChain.1.ts, 0, 9))
|
||||
>this : Symbol(A, Decl(privateIdentifierChain.1.ts, 0, 0))
|
||||
>a : Symbol(A.a, Decl(privateIdentifierChain.1.ts, 0, 9))
|
||||
|
||||
this?.getA().#b; // Error
|
||||
>this?.getA : Symbol(A.getA, Decl(privateIdentifierChain.1.ts, 2, 11))
|
||||
>this : Symbol(A, Decl(privateIdentifierChain.1.ts, 0, 0))
|
||||
>getA : Symbol(A.getA, Decl(privateIdentifierChain.1.ts, 2, 11))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
=== tests/cases/conformance/expressions/optionalChaining/privateIdentifierChain/privateIdentifierChain.1.ts ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
a?: A
|
||||
>a : A | undefined
|
||||
|
||||
#b?: A;
|
||||
>#b : A | undefined
|
||||
|
||||
getA(): A {
|
||||
>getA : () => A
|
||||
|
||||
return new A();
|
||||
>new A() : A
|
||||
>A : typeof A
|
||||
}
|
||||
constructor() {
|
||||
this?.#b; // Error
|
||||
>this?.#b : any
|
||||
>this : this
|
||||
|
||||
this?.a.#b; // Error
|
||||
>this?.a.#b : any
|
||||
>this?.a : A | undefined
|
||||
>this : this
|
||||
>a : A | undefined
|
||||
|
||||
this?.getA().#b; // Error
|
||||
>this?.getA().#b : any
|
||||
>this?.getA() : A | undefined
|
||||
>this?.getA : (() => A) | undefined
|
||||
>this : this
|
||||
>getA : (() => A) | undefined
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(5,15): error TS2339: Property '#bar' does not exist on type 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts (1 errors) ====
|
||||
class A {
|
||||
#foo = true;
|
||||
method(thing: any) {
|
||||
thing.#foo; // OK
|
||||
thing.#bar; // Error
|
||||
~~~~
|
||||
!!! error TS2339: Property '#bar' does not exist on type 'any'.
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//// [privateNameAndAny.ts]
|
||||
class A {
|
||||
#foo = true;
|
||||
method(thing: any) {
|
||||
thing.#foo; // OK
|
||||
thing.#bar; // Error
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//// [privateNameAndAny.js]
|
||||
"use strict";
|
||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to get private field on non-instance");
|
||||
}
|
||||
return privateMap.get(receiver);
|
||||
};
|
||||
var _foo;
|
||||
class A {
|
||||
constructor() {
|
||||
_foo.set(this, true);
|
||||
}
|
||||
method(thing) {
|
||||
__classPrivateFieldGet(thing, _foo); // OK
|
||||
thing.; // Error
|
||||
}
|
||||
}
|
||||
_foo = new WeakMap();
|
||||
;
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts ===
|
||||
class A {
|
||||
>A : Symbol(A, Decl(privateNameAndAny.ts, 0, 0))
|
||||
|
||||
#foo = true;
|
||||
>#foo : Symbol(A.#foo, Decl(privateNameAndAny.ts, 0, 9))
|
||||
|
||||
method(thing: any) {
|
||||
>method : Symbol(A.method, Decl(privateNameAndAny.ts, 1, 16))
|
||||
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 2, 11))
|
||||
|
||||
thing.#foo; // OK
|
||||
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 2, 11))
|
||||
|
||||
thing.#bar; // Error
|
||||
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 2, 11))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
#foo = true;
|
||||
>#foo : boolean
|
||||
>true : true
|
||||
|
||||
method(thing: any) {
|
||||
>method : (thing: any) => void
|
||||
>thing : any
|
||||
|
||||
thing.#foo; // OK
|
||||
>thing.#foo : any
|
||||
>thing : any
|
||||
|
||||
thing.#bar; // Error
|
||||
>thing.#bar : any
|
||||
>thing : any
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameAndIndexSignature.ts(4,5): error TS7022: '["#bar"]' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameAndIndexSignature.ts(6,14): error TS2339: Property '#f' does not exist on type 'A'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameAndIndexSignature.ts (2 errors) ====
|
||||
class A {
|
||||
[k: string]: any;
|
||||
#foo = 3;
|
||||
["#bar"] = this["#bar"] // Error (private identifiers should not prevent circularity checking for computeds)
|
||||
~~~~~~~~
|
||||
!!! error TS7022: '["#bar"]' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
|
||||
constructor(message: string) {
|
||||
this.#f = 3 // Error (index signatures do not implicitly declare private names)
|
||||
~~
|
||||
!!! error TS2339: Property '#f' does not exist on type 'A'.
|
||||
this["#foo"] = 3; // Okay (type has index signature and "#foo" does not collide with private identifier #foo)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [privateNameAndIndexSignature.ts]
|
||||
class A {
|
||||
[k: string]: any;
|
||||
#foo = 3;
|
||||
["#bar"] = this["#bar"] // Error (private identifiers should not prevent circularity checking for computeds)
|
||||
constructor(message: string) {
|
||||
this.#f = 3 // Error (index signatures do not implicitly declare private names)
|
||||
this["#foo"] = 3; // Okay (type has index signature and "#foo" does not collide with private identifier #foo)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [privateNameAndIndexSignature.js]
|
||||
"use strict";
|
||||
var _foo;
|
||||
class A {
|
||||
constructor(message) {
|
||||
_foo.set(this, 3);
|
||||
this["#bar"] = this["#bar"]; // Error (private identifiers should not prevent circularity checking for computeds)
|
||||
this. = 3; // Error (index signatures do not implicitly declare private names)
|
||||
this["#foo"] = 3; // Okay (type has index signature and "#foo" does not collide with private identifier #foo)
|
||||
}
|
||||
}
|
||||
_foo = new WeakMap();
|
||||
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameAndIndexSignature.ts ===
|
||||
class A {
|
||||
>A : Symbol(A, Decl(privateNameAndIndexSignature.ts, 0, 0))
|
||||
|
||||
[k: string]: any;
|
||||
>k : Symbol(k, Decl(privateNameAndIndexSignature.ts, 1, 5))
|
||||
|
||||
#foo = 3;
|
||||
>#foo : Symbol(A.#foo, Decl(privateNameAndIndexSignature.ts, 1, 21))
|
||||
|
||||
["#bar"] = this["#bar"] // Error (private identifiers should not prevent circularity checking for computeds)
|
||||
>["#bar"] : Symbol(A["#bar"], Decl(privateNameAndIndexSignature.ts, 2, 13))
|
||||
>"#bar" : Symbol(A["#bar"], Decl(privateNameAndIndexSignature.ts, 2, 13))
|
||||
>this : Symbol(A, Decl(privateNameAndIndexSignature.ts, 0, 0))
|
||||
>"#bar" : Symbol(A["#bar"], Decl(privateNameAndIndexSignature.ts, 2, 13))
|
||||
|
||||
constructor(message: string) {
|
||||
>message : Symbol(message, Decl(privateNameAndIndexSignature.ts, 4, 16))
|
||||
|
||||
this.#f = 3 // Error (index signatures do not implicitly declare private names)
|
||||
>this : Symbol(A, Decl(privateNameAndIndexSignature.ts, 0, 0))
|
||||
|
||||
this["#foo"] = 3; // Okay (type has index signature and "#foo" does not collide with private identifier #foo)
|
||||
>this : Symbol(A, Decl(privateNameAndIndexSignature.ts, 0, 0))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameAndIndexSignature.ts ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
[k: string]: any;
|
||||
>k : string
|
||||
|
||||
#foo = 3;
|
||||
>#foo : number
|
||||
>3 : 3
|
||||
|
||||
["#bar"] = this["#bar"] // Error (private identifiers should not prevent circularity checking for computeds)
|
||||
>["#bar"] : any
|
||||
>"#bar" : "#bar"
|
||||
>this["#bar"] : any
|
||||
>this : this
|
||||
>"#bar" : "#bar"
|
||||
|
||||
constructor(message: string) {
|
||||
>message : string
|
||||
|
||||
this.#f = 3 // Error (index signatures do not implicitly declare private names)
|
||||
>this.#f = 3 : 3
|
||||
>this.#f : any
|
||||
>this : this
|
||||
>3 : 3
|
||||
|
||||
this["#foo"] = 3; // Okay (type has index signature and "#foo" does not collide with private identifier #foo)
|
||||
>this["#foo"] = 3 : 3
|
||||
>this["#foo"] : any
|
||||
>this : this
|
||||
>"#foo" : "#foo"
|
||||
>3 : 3
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user