From a36e023b7e200df4786a2a449617b8fac8e332f6 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Mon, 20 Jul 2020 13:24:34 +0300 Subject: [PATCH] fix(26325): use a unique name for reserved words in 'constructor like' function name --- src/compiler/transformers/es2015.ts | 11 +- ...ExpressionToFunctionFromObjectProperty1.js | 636 ++++++++++++++++ ...ssionToFunctionFromObjectProperty1.symbols | 398 ++++++++++ ...ressionToFunctionFromObjectProperty1.types | 711 ++++++++++++++++++ ...ExpressionToFunctionFromObjectProperty2.js | 635 ++++++++++++++++ ...ssionToFunctionFromObjectProperty2.symbols | 396 ++++++++++ ...ressionToFunctionFromObjectProperty2.types | 477 ++++++++++++ .../baselines/reference/convertKeywordsYes.js | 36 +- .../reference/strictModeReservedWord.js | 4 +- ...ExpressionToFunctionFromObjectProperty1.ts | 241 ++++++ ...ExpressionToFunctionFromObjectProperty2.ts | 240 ++++++ 11 files changed, 3760 insertions(+), 25 deletions(-) create mode 100644 tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.js create mode 100644 tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.symbols create mode 100644 tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.types create mode 100644 tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.js create mode 100644 tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.symbols create mode 100644 tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.types create mode 100644 tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty1.ts create mode 100644 tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty2.ts diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 02ff2c261e536..813ce25672b87 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -814,18 +814,19 @@ namespace ts { */ function transformClassBody(node: ClassExpression | ClassDeclaration, extendsClauseElement: ExpressionWithTypeArguments | undefined): Block { const statements: Statement[] = []; + const name = factory.getInternalName(node); + const constructorLikeName = isIdentifierANonContextualKeyword(name) ? factory.getGeneratedNameForNode(name) : name; startLexicalEnvironment(); addExtendsHelperIfNeeded(statements, node, extendsClauseElement); - addConstructor(statements, node, extendsClauseElement); + addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. const closingBraceLocation = createTokenRange(skipTrivia(currentText, node.members.end), SyntaxKind.CloseBraceToken); - const localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. - const outer = factory.createPartiallyEmittedExpression(localName); + const outer = factory.createPartiallyEmittedExpression(constructorLikeName); setTextRangeEnd(outer, closingBraceLocation.end); setEmitFlags(outer, EmitFlags.NoComments); @@ -868,7 +869,7 @@ namespace ts { * @param node The ClassExpression or ClassDeclaration node. * @param extendsClauseElement The expression for the class `extends` clause. */ - function addConstructor(statements: Statement[], node: ClassExpression | ClassDeclaration, extendsClauseElement: ExpressionWithTypeArguments | undefined): void { + function addConstructor(statements: Statement[], node: ClassExpression | ClassDeclaration, name: Identifier, extendsClauseElement: ExpressionWithTypeArguments | undefined): void { const savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; const ancestorFacts = enterSubtree(HierarchyFacts.ConstructorExcludes, HierarchyFacts.ConstructorIncludes); @@ -878,7 +879,7 @@ namespace ts { /*decorators*/ undefined, /*modifiers*/ undefined, /*asteriskToken*/ undefined, - factory.getInternalName(node), + name, /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), /*type*/ undefined, diff --git a/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.js b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.js new file mode 100644 index 0000000000000..1c2b4b8a44930 --- /dev/null +++ b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.js @@ -0,0 +1,636 @@ +//// [convertClassExpressionToFunctionFromObjectProperty1.ts] +const foo: any = {}; + +// properties +foo.x = class { + constructor () {} +} +foo.y = class { + constructor () {} +} + +// keywords +foo.break = class { + constructor () {} +} +foo.case = class { + constructor () {} +} +foo.catch = class { + constructor () {} +} +foo.class = class { + constructor () {} +} +foo.const = class { + constructor () {} +} +foo.continue = class { + constructor () {} +} +foo.debugger = class { + constructor () {} +} +foo.default = class { + constructor () {} +} +foo.delete = class { + constructor () {} +} +foo.do = class { + constructor () {} +} +foo.else = class { + constructor () {} +} +foo.enum = class { + constructor () {} +} +foo.export = class { + constructor () {} +} +foo.extends = class { + constructor () {} +} +foo.false = class { + constructor () {} +} +foo.finally = class { + constructor () {} +} +foo.for = class { + constructor () {} +} +foo.function = class { + constructor () {} +} +foo.if = class { + constructor () {} +} +foo.import = class { + constructor () {} +} +foo.in = class { + constructor () {} +} +foo.instanceof = class { + constructor () {} +} +foo.new = class { + constructor () {} +} +foo.null = class { + constructor () {} +} +foo.return = class { + constructor () {} +} +foo.super = class { + constructor () {} +} +foo.switch = class { + constructor () {} +} +foo.this = class { + constructor () {} +} +foo.throw = class { + constructor () {} +} +foo.true = class { + constructor () {} +} +foo.try = class { + constructor () {} +} +foo.typeof = class { + constructor () {} +} +foo.var = class { + constructor () {} +} +foo.void = class { + constructor () {} +} +foo.while = class { + constructor () {} +} +foo.with = class { + constructor () {} +} +foo.implements = class { + constructor () {} +} +foo.interface = class { + constructor () {} +} +foo.let = class { + constructor () {} +} +foo.package = class { + constructor () {} +} +foo.private = class { + constructor () {} +} +foo.protected = class { + constructor () {} +} +foo.public = class { + constructor () {} +} +foo.static = class { + constructor () {} +} +foo.yield = class { + constructor () {} +} +foo.abstract = class { + constructor () {} +} +foo.as = class { + constructor () {} +} +foo.asserts = class { + constructor () {} +} +foo.any = class { + constructor () {} +} +foo.async = class { + constructor () {} +} +foo.await = class { + constructor () {} +} +foo.boolean = class { + constructor () {} +} +foo.constructor = class { + constructor () {} +} +foo.declare = class { + constructor () {} +} +foo.get = class { + constructor () {} +} +foo.infer = class { + constructor () {} +} +foo.is = class { + constructor () {} +} +foo.keyof = class { + constructor () {} +} +foo.module = class { + constructor () {} +} +foo.namespace = class { + constructor () {} +} +foo.never = class { + constructor () {} +} +foo.readonly = class { + constructor () {} +} +foo.require = class { + constructor () {} +} +foo.number = class { + constructor () {} +} +foo.object = class { + constructor () {} +} +foo.set = class { + constructor () {} +} +foo.string = class { + constructor () {} +} +foo.symbol = class { + constructor () {} +} +foo.type = class { + constructor () {} +} +foo.undefined = class { + constructor () {} +} +foo.unique = class { + constructor () {} +} +foo.unknown = class { + constructor () {} +} +foo.from = class { + constructor () {} +} +foo.global = class { + constructor () {} +} +foo.bigint = class { + constructor () {} +} +foo.of = class { + constructor () {} +} + + +//// [convertClassExpressionToFunctionFromObjectProperty1.js] +var foo = {}; +// properties +foo.x = /** @class */ (function () { + function x() { + } + return x; +}()); +foo.y = /** @class */ (function () { + function y() { + } + return y; +}()); +// keywords +foo.break = /** @class */ (function () { + function break_1() { + } + return break_1; +}()); +foo.case = /** @class */ (function () { + function case_1() { + } + return case_1; +}()); +foo.catch = /** @class */ (function () { + function catch_1() { + } + return catch_1; +}()); +foo.class = /** @class */ (function () { + function class_1() { + } + return class_1; +}()); +foo.const = /** @class */ (function () { + function const_1() { + } + return const_1; +}()); +foo.continue = /** @class */ (function () { + function continue_1() { + } + return continue_1; +}()); +foo.debugger = /** @class */ (function () { + function debugger_1() { + } + return debugger_1; +}()); +foo.default = /** @class */ (function () { + function default_1() { + } + return default_1; +}()); +foo.delete = /** @class */ (function () { + function delete_1() { + } + return delete_1; +}()); +foo.do = /** @class */ (function () { + function do_1() { + } + return do_1; +}()); +foo.else = /** @class */ (function () { + function else_1() { + } + return else_1; +}()); +foo.enum = /** @class */ (function () { + function enum_1() { + } + return enum_1; +}()); +foo.export = /** @class */ (function () { + function export_1() { + } + return export_1; +}()); +foo.extends = /** @class */ (function () { + function extends_1() { + } + return extends_1; +}()); +foo.false = /** @class */ (function () { + function false_1() { + } + return false_1; +}()); +foo.finally = /** @class */ (function () { + function finally_1() { + } + return finally_1; +}()); +foo.for = /** @class */ (function () { + function for_1() { + } + return for_1; +}()); +foo.function = /** @class */ (function () { + function function_1() { + } + return function_1; +}()); +foo.if = /** @class */ (function () { + function if_1() { + } + return if_1; +}()); +foo.import = /** @class */ (function () { + function import_1() { + } + return import_1; +}()); +foo.in = /** @class */ (function () { + function in_1() { + } + return in_1; +}()); +foo.instanceof = /** @class */ (function () { + function instanceof_1() { + } + return instanceof_1; +}()); +foo.new = /** @class */ (function () { + function new_1() { + } + return new_1; +}()); +foo.null = /** @class */ (function () { + function null_1() { + } + return null_1; +}()); +foo.return = /** @class */ (function () { + function return_1() { + } + return return_1; +}()); +foo.super = /** @class */ (function () { + function super_1() { + } + return super_1; +}()); +foo.switch = /** @class */ (function () { + function switch_1() { + } + return switch_1; +}()); +foo.this = /** @class */ (function () { + function this_1() { + } + return this_1; +}()); +foo.throw = /** @class */ (function () { + function throw_1() { + } + return throw_1; +}()); +foo.true = /** @class */ (function () { + function true_1() { + } + return true_1; +}()); +foo.try = /** @class */ (function () { + function try_1() { + } + return try_1; +}()); +foo.typeof = /** @class */ (function () { + function typeof_1() { + } + return typeof_1; +}()); +foo.var = /** @class */ (function () { + function var_1() { + } + return var_1; +}()); +foo.void = /** @class */ (function () { + function void_1() { + } + return void_1; +}()); +foo.while = /** @class */ (function () { + function while_1() { + } + return while_1; +}()); +foo.with = /** @class */ (function () { + function with_1() { + } + return with_1; +}()); +foo.implements = /** @class */ (function () { + function implements_1() { + } + return implements_1; +}()); +foo.interface = /** @class */ (function () { + function interface_1() { + } + return interface_1; +}()); +foo.let = /** @class */ (function () { + function let_1() { + } + return let_1; +}()); +foo.package = /** @class */ (function () { + function package_1() { + } + return package_1; +}()); +foo.private = /** @class */ (function () { + function private_1() { + } + return private_1; +}()); +foo.protected = /** @class */ (function () { + function protected_1() { + } + return protected_1; +}()); +foo.public = /** @class */ (function () { + function public_1() { + } + return public_1; +}()); +foo.static = /** @class */ (function () { + function static_1() { + } + return static_1; +}()); +foo.yield = /** @class */ (function () { + function yield_1() { + } + return yield_1; +}()); +foo.abstract = /** @class */ (function () { + function abstract() { + } + return abstract; +}()); +foo.as = /** @class */ (function () { + function as() { + } + return as; +}()); +foo.asserts = /** @class */ (function () { + function asserts() { + } + return asserts; +}()); +foo.any = /** @class */ (function () { + function any() { + } + return any; +}()); +foo.async = /** @class */ (function () { + function async() { + } + return async; +}()); +foo.await = /** @class */ (function () { + function await() { + } + return await; +}()); +foo.boolean = /** @class */ (function () { + function boolean() { + } + return boolean; +}()); +foo.constructor = /** @class */ (function () { + function constructor() { + } + return constructor; +}()); +foo.declare = /** @class */ (function () { + function declare() { + } + return declare; +}()); +foo.get = /** @class */ (function () { + function get() { + } + return get; +}()); +foo.infer = /** @class */ (function () { + function infer() { + } + return infer; +}()); +foo.is = /** @class */ (function () { + function is() { + } + return is; +}()); +foo.keyof = /** @class */ (function () { + function keyof() { + } + return keyof; +}()); +foo.module = /** @class */ (function () { + function module() { + } + return module; +}()); +foo.namespace = /** @class */ (function () { + function namespace() { + } + return namespace; +}()); +foo.never = /** @class */ (function () { + function never() { + } + return never; +}()); +foo.readonly = /** @class */ (function () { + function readonly() { + } + return readonly; +}()); +foo.require = /** @class */ (function () { + function require() { + } + return require; +}()); +foo.number = /** @class */ (function () { + function number() { + } + return number; +}()); +foo.object = /** @class */ (function () { + function object() { + } + return object; +}()); +foo.set = /** @class */ (function () { + function set() { + } + return set; +}()); +foo.string = /** @class */ (function () { + function string() { + } + return string; +}()); +foo.symbol = /** @class */ (function () { + function symbol() { + } + return symbol; +}()); +foo.type = /** @class */ (function () { + function type() { + } + return type; +}()); +foo.undefined = /** @class */ (function () { + function undefined() { + } + return undefined; +}()); +foo.unique = /** @class */ (function () { + function unique() { + } + return unique; +}()); +foo.unknown = /** @class */ (function () { + function unknown() { + } + return unknown; +}()); +foo.from = /** @class */ (function () { + function from() { + } + return from; +}()); +foo.global = /** @class */ (function () { + function global() { + } + return global; +}()); +foo.bigint = /** @class */ (function () { + function bigint() { + } + return bigint; +}()); +foo.of = /** @class */ (function () { + function of() { + } + return of; +}()); diff --git a/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.symbols b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.symbols new file mode 100644 index 0000000000000..923b52e7e149a --- /dev/null +++ b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.symbols @@ -0,0 +1,398 @@ +=== tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty1.ts === +const foo: any = {}; +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + +// properties +foo.x = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.y = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} + +// keywords +foo.break = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.case = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.catch = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.class = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.const = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.continue = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.debugger = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.default = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.delete = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.do = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.else = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.enum = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.export = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.extends = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.false = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.finally = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.for = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.function = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.if = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.import = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.in = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.instanceof = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.new = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.null = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.return = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.super = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.switch = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.this = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.throw = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.true = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.try = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.typeof = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.var = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.void = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.while = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.with = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.implements = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.interface = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.let = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.package = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.private = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.protected = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.public = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.static = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.yield = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.abstract = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.as = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.asserts = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.any = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.async = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.await = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.boolean = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.constructor = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.declare = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.get = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.infer = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.is = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.keyof = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.module = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.namespace = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.never = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.readonly = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.require = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.number = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.object = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.set = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.string = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.symbol = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.type = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.undefined = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.unique = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.unknown = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.from = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.global = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.bigint = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} +foo.of = class { +>foo : Symbol(foo, Decl(convertClassExpressionToFunctionFromObjectProperty1.ts, 0, 5)) + + constructor () {} +} + diff --git a/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.types b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.types new file mode 100644 index 0000000000000..045947b6a924a --- /dev/null +++ b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty1.types @@ -0,0 +1,711 @@ +=== tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty1.ts === +const foo: any = {}; +>foo : any +>{} : {} + +// properties +foo.x = class { +>foo.x = class { constructor () {}} : typeof x +>foo.x : any +>foo : any +>x : any +>class { constructor () {}} : typeof x + + constructor () {} +} +foo.y = class { +>foo.y = class { constructor () {}} : typeof y +>foo.y : any +>foo : any +>y : any +>class { constructor () {}} : typeof y + + constructor () {} +} + +// keywords +foo.break = class { +>foo.break = class { constructor () {}} : typeof break +>foo.break : any +>foo : any +>break : any +>class { constructor () {}} : typeof break + + constructor () {} +} +foo.case = class { +>foo.case = class { constructor () {}} : typeof case +>foo.case : any +>foo : any +>case : any +>class { constructor () {}} : typeof case + + constructor () {} +} +foo.catch = class { +>foo.catch = class { constructor () {}} : typeof catch +>foo.catch : any +>foo : any +>catch : any +>class { constructor () {}} : typeof catch + + constructor () {} +} +foo.class = class { +>foo.class = class { constructor () {}} : typeof class +>foo.class : any +>foo : any +>class : any +>class { constructor () {}} : typeof class + + constructor () {} +} +foo.const = class { +>foo.const = class { constructor () {}} : typeof const +>foo.const : any +>foo : any +>const : any +>class { constructor () {}} : typeof const + + constructor () {} +} +foo.continue = class { +>foo.continue = class { constructor () {}} : typeof continue +>foo.continue : any +>foo : any +>continue : any +>class { constructor () {}} : typeof continue + + constructor () {} +} +foo.debugger = class { +>foo.debugger = class { constructor () {}} : typeof debugger +>foo.debugger : any +>foo : any +>debugger : any +>class { constructor () {}} : typeof debugger + + constructor () {} +} +foo.default = class { +>foo.default = class { constructor () {}} : typeof default +>foo.default : any +>foo : any +>default : any +>class { constructor () {}} : typeof default + + constructor () {} +} +foo.delete = class { +>foo.delete = class { constructor () {}} : typeof delete +>foo.delete : any +>foo : any +>delete : any +>class { constructor () {}} : typeof delete + + constructor () {} +} +foo.do = class { +>foo.do = class { constructor () {}} : typeof do +>foo.do : any +>foo : any +>do : any +>class { constructor () {}} : typeof do + + constructor () {} +} +foo.else = class { +>foo.else = class { constructor () {}} : typeof else +>foo.else : any +>foo : any +>else : any +>class { constructor () {}} : typeof else + + constructor () {} +} +foo.enum = class { +>foo.enum = class { constructor () {}} : typeof enum +>foo.enum : any +>foo : any +>enum : any +>class { constructor () {}} : typeof enum + + constructor () {} +} +foo.export = class { +>foo.export = class { constructor () {}} : typeof export +>foo.export : any +>foo : any +>export : any +>class { constructor () {}} : typeof export + + constructor () {} +} +foo.extends = class { +>foo.extends = class { constructor () {}} : typeof extends +>foo.extends : any +>foo : any +>extends : any +>class { constructor () {}} : typeof extends + + constructor () {} +} +foo.false = class { +>foo.false = class { constructor () {}} : typeof false +>foo.false : any +>foo : any +>false : any +>class { constructor () {}} : typeof false + + constructor () {} +} +foo.finally = class { +>foo.finally = class { constructor () {}} : typeof finally +>foo.finally : any +>foo : any +>finally : any +>class { constructor () {}} : typeof finally + + constructor () {} +} +foo.for = class { +>foo.for = class { constructor () {}} : typeof for +>foo.for : any +>foo : any +>for : any +>class { constructor () {}} : typeof for + + constructor () {} +} +foo.function = class { +>foo.function = class { constructor () {}} : typeof function +>foo.function : any +>foo : any +>function : any +>class { constructor () {}} : typeof function + + constructor () {} +} +foo.if = class { +>foo.if = class { constructor () {}} : typeof if +>foo.if : any +>foo : any +>if : any +>class { constructor () {}} : typeof if + + constructor () {} +} +foo.import = class { +>foo.import = class { constructor () {}} : typeof import +>foo.import : any +>foo : any +>import : any +>class { constructor () {}} : typeof import + + constructor () {} +} +foo.in = class { +>foo.in = class { constructor () {}} : typeof in +>foo.in : any +>foo : any +>in : any +>class { constructor () {}} : typeof in + + constructor () {} +} +foo.instanceof = class { +>foo.instanceof = class { constructor () {}} : typeof instanceof +>foo.instanceof : any +>foo : any +>instanceof : any +>class { constructor () {}} : typeof instanceof + + constructor () {} +} +foo.new = class { +>foo.new = class { constructor () {}} : typeof new +>foo.new : any +>foo : any +>new : any +>class { constructor () {}} : typeof new + + constructor () {} +} +foo.null = class { +>foo.null = class { constructor () {}} : typeof null +>foo.null : any +>foo : any +>null : any +>class { constructor () {}} : typeof null + + constructor () {} +} +foo.return = class { +>foo.return = class { constructor () {}} : typeof return +>foo.return : any +>foo : any +>return : any +>class { constructor () {}} : typeof return + + constructor () {} +} +foo.super = class { +>foo.super = class { constructor () {}} : typeof super +>foo.super : any +>foo : any +>super : any +>class { constructor () {}} : typeof super + + constructor () {} +} +foo.switch = class { +>foo.switch = class { constructor () {}} : typeof switch +>foo.switch : any +>foo : any +>switch : any +>class { constructor () {}} : typeof switch + + constructor () {} +} +foo.this = class { +>foo.this = class { constructor () {}} : typeof this +>foo.this : any +>foo : any +>this : any +>class { constructor () {}} : typeof this + + constructor () {} +} +foo.throw = class { +>foo.throw = class { constructor () {}} : typeof throw +>foo.throw : any +>foo : any +>throw : any +>class { constructor () {}} : typeof throw + + constructor () {} +} +foo.true = class { +>foo.true = class { constructor () {}} : typeof true +>foo.true : any +>foo : any +>true : any +>class { constructor () {}} : typeof true + + constructor () {} +} +foo.try = class { +>foo.try = class { constructor () {}} : typeof try +>foo.try : any +>foo : any +>try : any +>class { constructor () {}} : typeof try + + constructor () {} +} +foo.typeof = class { +>foo.typeof = class { constructor () {}} : typeof typeof +>foo.typeof : any +>foo : any +>typeof : any +>class { constructor () {}} : typeof typeof + + constructor () {} +} +foo.var = class { +>foo.var = class { constructor () {}} : typeof var +>foo.var : any +>foo : any +>var : any +>class { constructor () {}} : typeof var + + constructor () {} +} +foo.void = class { +>foo.void = class { constructor () {}} : typeof void +>foo.void : any +>foo : any +>void : any +>class { constructor () {}} : typeof void + + constructor () {} +} +foo.while = class { +>foo.while = class { constructor () {}} : typeof while +>foo.while : any +>foo : any +>while : any +>class { constructor () {}} : typeof while + + constructor () {} +} +foo.with = class { +>foo.with = class { constructor () {}} : typeof with +>foo.with : any +>foo : any +>with : any +>class { constructor () {}} : typeof with + + constructor () {} +} +foo.implements = class { +>foo.implements = class { constructor () {}} : typeof implements +>foo.implements : any +>foo : any +>implements : any +>class { constructor () {}} : typeof implements + + constructor () {} +} +foo.interface = class { +>foo.interface = class { constructor () {}} : typeof interface +>foo.interface : any +>foo : any +>interface : any +>class { constructor () {}} : typeof interface + + constructor () {} +} +foo.let = class { +>foo.let = class { constructor () {}} : typeof let +>foo.let : any +>foo : any +>let : any +>class { constructor () {}} : typeof let + + constructor () {} +} +foo.package = class { +>foo.package = class { constructor () {}} : typeof package +>foo.package : any +>foo : any +>package : any +>class { constructor () {}} : typeof package + + constructor () {} +} +foo.private = class { +>foo.private = class { constructor () {}} : typeof private +>foo.private : any +>foo : any +>private : any +>class { constructor () {}} : typeof private + + constructor () {} +} +foo.protected = class { +>foo.protected = class { constructor () {}} : typeof protected +>foo.protected : any +>foo : any +>protected : any +>class { constructor () {}} : typeof protected + + constructor () {} +} +foo.public = class { +>foo.public = class { constructor () {}} : typeof public +>foo.public : any +>foo : any +>public : any +>class { constructor () {}} : typeof public + + constructor () {} +} +foo.static = class { +>foo.static = class { constructor () {}} : typeof static +>foo.static : any +>foo : any +>static : any +>class { constructor () {}} : typeof static + + constructor () {} +} +foo.yield = class { +>foo.yield = class { constructor () {}} : typeof yield +>foo.yield : any +>foo : any +>yield : any +>class { constructor () {}} : typeof yield + + constructor () {} +} +foo.abstract = class { +>foo.abstract = class { constructor () {}} : typeof abstract +>foo.abstract : any +>foo : any +>abstract : any +>class { constructor () {}} : typeof abstract + + constructor () {} +} +foo.as = class { +>foo.as = class { constructor () {}} : typeof as +>foo.as : any +>foo : any +>as : any +>class { constructor () {}} : typeof as + + constructor () {} +} +foo.asserts = class { +>foo.asserts = class { constructor () {}} : typeof asserts +>foo.asserts : any +>foo : any +>asserts : any +>class { constructor () {}} : typeof asserts + + constructor () {} +} +foo.any = class { +>foo.any = class { constructor () {}} : typeof any +>foo.any : any +>foo : any +>any : any +>class { constructor () {}} : typeof any + + constructor () {} +} +foo.async = class { +>foo.async = class { constructor () {}} : typeof async +>foo.async : any +>foo : any +>async : any +>class { constructor () {}} : typeof async + + constructor () {} +} +foo.await = class { +>foo.await = class { constructor () {}} : typeof await +>foo.await : any +>foo : any +>await : any +>class { constructor () {}} : typeof await + + constructor () {} +} +foo.boolean = class { +>foo.boolean = class { constructor () {}} : typeof boolean +>foo.boolean : any +>foo : any +>boolean : any +>class { constructor () {}} : typeof boolean + + constructor () {} +} +foo.constructor = class { +>foo.constructor = class { constructor () {}} : typeof constructor +>foo.constructor : any +>foo : any +>constructor : any +>class { constructor () {}} : typeof constructor + + constructor () {} +} +foo.declare = class { +>foo.declare = class { constructor () {}} : typeof declare +>foo.declare : any +>foo : any +>declare : any +>class { constructor () {}} : typeof declare + + constructor () {} +} +foo.get = class { +>foo.get = class { constructor () {}} : typeof get +>foo.get : any +>foo : any +>get : any +>class { constructor () {}} : typeof get + + constructor () {} +} +foo.infer = class { +>foo.infer = class { constructor () {}} : typeof infer +>foo.infer : any +>foo : any +>infer : any +>class { constructor () {}} : typeof infer + + constructor () {} +} +foo.is = class { +>foo.is = class { constructor () {}} : typeof is +>foo.is : any +>foo : any +>is : any +>class { constructor () {}} : typeof is + + constructor () {} +} +foo.keyof = class { +>foo.keyof = class { constructor () {}} : typeof keyof +>foo.keyof : any +>foo : any +>keyof : any +>class { constructor () {}} : typeof keyof + + constructor () {} +} +foo.module = class { +>foo.module = class { constructor () {}} : typeof module +>foo.module : any +>foo : any +>module : any +>class { constructor () {}} : typeof module + + constructor () {} +} +foo.namespace = class { +>foo.namespace = class { constructor () {}} : typeof namespace +>foo.namespace : any +>foo : any +>namespace : any +>class { constructor () {}} : typeof namespace + + constructor () {} +} +foo.never = class { +>foo.never = class { constructor () {}} : typeof never +>foo.never : any +>foo : any +>never : any +>class { constructor () {}} : typeof never + + constructor () {} +} +foo.readonly = class { +>foo.readonly = class { constructor () {}} : typeof readonly +>foo.readonly : any +>foo : any +>readonly : any +>class { constructor () {}} : typeof readonly + + constructor () {} +} +foo.require = class { +>foo.require = class { constructor () {}} : typeof require +>foo.require : any +>foo : any +>require : any +>class { constructor () {}} : typeof require + + constructor () {} +} +foo.number = class { +>foo.number = class { constructor () {}} : typeof number +>foo.number : any +>foo : any +>number : any +>class { constructor () {}} : typeof number + + constructor () {} +} +foo.object = class { +>foo.object = class { constructor () {}} : typeof object +>foo.object : any +>foo : any +>object : any +>class { constructor () {}} : typeof object + + constructor () {} +} +foo.set = class { +>foo.set = class { constructor () {}} : typeof set +>foo.set : any +>foo : any +>set : any +>class { constructor () {}} : typeof set + + constructor () {} +} +foo.string = class { +>foo.string = class { constructor () {}} : typeof string +>foo.string : any +>foo : any +>string : any +>class { constructor () {}} : typeof string + + constructor () {} +} +foo.symbol = class { +>foo.symbol = class { constructor () {}} : typeof symbol +>foo.symbol : any +>foo : any +>symbol : any +>class { constructor () {}} : typeof symbol + + constructor () {} +} +foo.type = class { +>foo.type = class { constructor () {}} : typeof type +>foo.type : any +>foo : any +>type : any +>class { constructor () {}} : typeof type + + constructor () {} +} +foo.undefined = class { +>foo.undefined = class { constructor () {}} : typeof undefined +>foo.undefined : any +>foo : any +>undefined : any +>class { constructor () {}} : typeof undefined + + constructor () {} +} +foo.unique = class { +>foo.unique = class { constructor () {}} : typeof unique +>foo.unique : any +>foo : any +>unique : any +>class { constructor () {}} : typeof unique + + constructor () {} +} +foo.unknown = class { +>foo.unknown = class { constructor () {}} : typeof unknown +>foo.unknown : any +>foo : any +>unknown : any +>class { constructor () {}} : typeof unknown + + constructor () {} +} +foo.from = class { +>foo.from = class { constructor () {}} : typeof from +>foo.from : any +>foo : any +>from : any +>class { constructor () {}} : typeof from + + constructor () {} +} +foo.global = class { +>foo.global = class { constructor () {}} : typeof global +>foo.global : any +>foo : any +>global : any +>class { constructor () {}} : typeof global + + constructor () {} +} +foo.bigint = class { +>foo.bigint = class { constructor () {}} : typeof bigint +>foo.bigint : any +>foo : any +>bigint : any +>class { constructor () {}} : typeof bigint + + constructor () {} +} +foo.of = class { +>foo.of = class { constructor () {}} : typeof of +>foo.of : any +>foo : any +>of : any +>class { constructor () {}} : typeof of + + constructor () {} +} + diff --git a/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.js b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.js new file mode 100644 index 0000000000000..f5962ddcae064 --- /dev/null +++ b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.js @@ -0,0 +1,635 @@ +//// [convertClassExpressionToFunctionFromObjectProperty2.ts] +({ + x: class { + constructor() { } + }, + y: class { + constructor() { } + }, + + // keywords + break: class { + constructor() { } + }, + case: class { + constructor() { } + }, + catch: class { + constructor() { } + }, + class: class { + constructor() { } + }, + const: class { + constructor() { } + }, + continue: class { + constructor() { } + }, + debugger: class { + constructor() { } + }, + default: class { + constructor() { } + }, + delete: class { + constructor() { } + }, + do: class { + constructor() { } + }, + else: class { + constructor() { } + }, + enum: class { + constructor() { } + }, + export: class { + constructor() { } + }, + extends: class { + constructor() { } + }, + false: class { + constructor() { } + }, + finally: class { + constructor() { } + }, + for: class { + constructor() { } + }, + function: class { + constructor() { } + }, + if: class { + constructor() { } + }, + import: class { + constructor() { } + }, + in: class { + constructor() { } + }, + instanceof: class { + constructor() { } + }, + new: class { + constructor() { } + }, + null: class { + constructor() { } + }, + return: class { + constructor() { } + }, + super: class { + constructor() { } + }, + switch: class { + constructor() { } + }, + this: class { + constructor() { } + }, + throw: class { + constructor() { } + }, + true: class { + constructor() { } + }, + try: class { + constructor() { } + }, + typeof: class { + constructor() { } + }, + var: class { + constructor() { } + }, + void: class { + constructor() { } + }, + while: class { + constructor() { } + }, + with: class { + constructor() { } + }, + implements: class { + constructor() { } + }, + interface: class { + constructor() { } + }, + let: class { + constructor() { } + }, + package: class { + constructor() { } + }, + private: class { + constructor() { } + }, + protected: class { + constructor() { } + }, + public: class { + constructor() { } + }, + static: class { + constructor() { } + }, + yield: class { + constructor() { } + }, + abstract: class { + constructor() { } + }, + as: class { + constructor() { } + }, + asserts: class { + constructor() { } + }, + any: class { + constructor() { } + }, + async: class { + constructor() { } + }, + await: class { + constructor() { } + }, + boolean: class { + constructor() { } + }, + constructor: class { + constructor() { } + }, + declare: class { + constructor() { } + }, + get: class { + constructor() { } + }, + infer: class { + constructor() { } + }, + is: class { + constructor() { } + }, + keyof: class { + constructor() { } + }, + module: class { + constructor() { } + }, + namespace: class { + constructor() { } + }, + never: class { + constructor() { } + }, + readonly: class { + constructor() { } + }, + require: class { + constructor() { } + }, + number: class { + constructor() { } + }, + object: class { + constructor() { } + }, + set: class { + constructor() { } + }, + string: class { + constructor() { } + }, + symbol: class { + constructor() { } + }, + type: class { + constructor() { } + }, + undefined: class { + constructor() { } + }, + unique: class { + constructor() { } + }, + unknown: class { + constructor() { } + }, + from: class { + constructor() { } + }, + global: class { + constructor() { } + }, + bigint: class { + constructor() { } + }, + of: class { + constructor() { } + } +}) + + +//// [convertClassExpressionToFunctionFromObjectProperty2.js] +({ + x: /** @class */ (function () { + function x() { + } + return x; + }()), + y: /** @class */ (function () { + function y() { + } + return y; + }()), + // keywords + break: /** @class */ (function () { + function break_1() { + } + return break_1; + }()), + case: /** @class */ (function () { + function case_1() { + } + return case_1; + }()), + catch: /** @class */ (function () { + function catch_1() { + } + return catch_1; + }()), + class: /** @class */ (function () { + function class_1() { + } + return class_1; + }()), + const: /** @class */ (function () { + function const_1() { + } + return const_1; + }()), + continue: /** @class */ (function () { + function continue_1() { + } + return continue_1; + }()), + debugger: /** @class */ (function () { + function debugger_1() { + } + return debugger_1; + }()), + default: /** @class */ (function () { + function default_1() { + } + return default_1; + }()), + delete: /** @class */ (function () { + function delete_1() { + } + return delete_1; + }()), + do: /** @class */ (function () { + function do_1() { + } + return do_1; + }()), + else: /** @class */ (function () { + function else_1() { + } + return else_1; + }()), + enum: /** @class */ (function () { + function enum_1() { + } + return enum_1; + }()), + export: /** @class */ (function () { + function export_1() { + } + return export_1; + }()), + extends: /** @class */ (function () { + function extends_1() { + } + return extends_1; + }()), + false: /** @class */ (function () { + function false_1() { + } + return false_1; + }()), + finally: /** @class */ (function () { + function finally_1() { + } + return finally_1; + }()), + for: /** @class */ (function () { + function for_1() { + } + return for_1; + }()), + function: /** @class */ (function () { + function function_1() { + } + return function_1; + }()), + if: /** @class */ (function () { + function if_1() { + } + return if_1; + }()), + import: /** @class */ (function () { + function import_1() { + } + return import_1; + }()), + in: /** @class */ (function () { + function in_1() { + } + return in_1; + }()), + instanceof: /** @class */ (function () { + function instanceof_1() { + } + return instanceof_1; + }()), + new: /** @class */ (function () { + function new_1() { + } + return new_1; + }()), + null: /** @class */ (function () { + function null_1() { + } + return null_1; + }()), + return: /** @class */ (function () { + function return_1() { + } + return return_1; + }()), + super: /** @class */ (function () { + function super_1() { + } + return super_1; + }()), + switch: /** @class */ (function () { + function switch_1() { + } + return switch_1; + }()), + this: /** @class */ (function () { + function this_1() { + } + return this_1; + }()), + throw: /** @class */ (function () { + function throw_1() { + } + return throw_1; + }()), + true: /** @class */ (function () { + function true_1() { + } + return true_1; + }()), + try: /** @class */ (function () { + function try_1() { + } + return try_1; + }()), + typeof: /** @class */ (function () { + function typeof_1() { + } + return typeof_1; + }()), + var: /** @class */ (function () { + function var_1() { + } + return var_1; + }()), + void: /** @class */ (function () { + function void_1() { + } + return void_1; + }()), + while: /** @class */ (function () { + function while_1() { + } + return while_1; + }()), + with: /** @class */ (function () { + function with_1() { + } + return with_1; + }()), + implements: /** @class */ (function () { + function implements_1() { + } + return implements_1; + }()), + interface: /** @class */ (function () { + function interface_1() { + } + return interface_1; + }()), + let: /** @class */ (function () { + function let_1() { + } + return let_1; + }()), + package: /** @class */ (function () { + function package_1() { + } + return package_1; + }()), + private: /** @class */ (function () { + function private_1() { + } + return private_1; + }()), + protected: /** @class */ (function () { + function protected_1() { + } + return protected_1; + }()), + public: /** @class */ (function () { + function public_1() { + } + return public_1; + }()), + static: /** @class */ (function () { + function static_1() { + } + return static_1; + }()), + yield: /** @class */ (function () { + function yield_1() { + } + return yield_1; + }()), + abstract: /** @class */ (function () { + function abstract() { + } + return abstract; + }()), + as: /** @class */ (function () { + function as() { + } + return as; + }()), + asserts: /** @class */ (function () { + function asserts() { + } + return asserts; + }()), + any: /** @class */ (function () { + function any() { + } + return any; + }()), + async: /** @class */ (function () { + function async() { + } + return async; + }()), + await: /** @class */ (function () { + function await() { + } + return await; + }()), + boolean: /** @class */ (function () { + function boolean() { + } + return boolean; + }()), + constructor: /** @class */ (function () { + function constructor() { + } + return constructor; + }()), + declare: /** @class */ (function () { + function declare() { + } + return declare; + }()), + get: /** @class */ (function () { + function get() { + } + return get; + }()), + infer: /** @class */ (function () { + function infer() { + } + return infer; + }()), + is: /** @class */ (function () { + function is() { + } + return is; + }()), + keyof: /** @class */ (function () { + function keyof() { + } + return keyof; + }()), + module: /** @class */ (function () { + function module() { + } + return module; + }()), + namespace: /** @class */ (function () { + function namespace() { + } + return namespace; + }()), + never: /** @class */ (function () { + function never() { + } + return never; + }()), + readonly: /** @class */ (function () { + function readonly() { + } + return readonly; + }()), + require: /** @class */ (function () { + function require() { + } + return require; + }()), + number: /** @class */ (function () { + function number() { + } + return number; + }()), + object: /** @class */ (function () { + function object() { + } + return object; + }()), + set: /** @class */ (function () { + function set() { + } + return set; + }()), + string: /** @class */ (function () { + function string() { + } + return string; + }()), + symbol: /** @class */ (function () { + function symbol() { + } + return symbol; + }()), + type: /** @class */ (function () { + function type() { + } + return type; + }()), + undefined: /** @class */ (function () { + function undefined() { + } + return undefined; + }()), + unique: /** @class */ (function () { + function unique() { + } + return unique; + }()), + unknown: /** @class */ (function () { + function unknown() { + } + return unknown; + }()), + from: /** @class */ (function () { + function from() { + } + return from; + }()), + global: /** @class */ (function () { + function global() { + } + return global; + }()), + bigint: /** @class */ (function () { + function bigint() { + } + return bigint; + }()), + of: /** @class */ (function () { + function of() { + } + return of; + }()) +}); diff --git a/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.symbols b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.symbols new file mode 100644 index 0000000000000..aeb1957cdcf44 --- /dev/null +++ b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.symbols @@ -0,0 +1,396 @@ +=== tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty2.ts === +({ + x: class { +>x : Symbol(x, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 0, 2)) + + constructor() { } + }, + y: class { +>y : Symbol(y, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 3, 6)) + + constructor() { } + }, + + // keywords + break: class { +>break : Symbol(break, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 6, 6)) + + constructor() { } + }, + case: class { +>case : Symbol(case, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 11, 6)) + + constructor() { } + }, + catch: class { +>catch : Symbol(catch, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 14, 6)) + + constructor() { } + }, + class: class { +>class : Symbol(class, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 17, 6)) + + constructor() { } + }, + const: class { +>const : Symbol(const, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 20, 6)) + + constructor() { } + }, + continue: class { +>continue : Symbol(continue, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 23, 6)) + + constructor() { } + }, + debugger: class { +>debugger : Symbol(debugger, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 26, 6)) + + constructor() { } + }, + default: class { +>default : Symbol(default, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 29, 6)) + + constructor() { } + }, + delete: class { +>delete : Symbol(delete, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 32, 6)) + + constructor() { } + }, + do: class { +>do : Symbol(do, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 35, 6)) + + constructor() { } + }, + else: class { +>else : Symbol(else, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 38, 6)) + + constructor() { } + }, + enum: class { +>enum : Symbol(enum, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 41, 6)) + + constructor() { } + }, + export: class { +>export : Symbol(export, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 44, 6)) + + constructor() { } + }, + extends: class { +>extends : Symbol(extends, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 47, 6)) + + constructor() { } + }, + false: class { +>false : Symbol(false, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 50, 6)) + + constructor() { } + }, + finally: class { +>finally : Symbol(finally, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 53, 6)) + + constructor() { } + }, + for: class { +>for : Symbol(for, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 56, 6)) + + constructor() { } + }, + function: class { +>function : Symbol(function, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 59, 6)) + + constructor() { } + }, + if: class { +>if : Symbol(if, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 62, 6)) + + constructor() { } + }, + import: class { +>import : Symbol(import, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 65, 6)) + + constructor() { } + }, + in: class { +>in : Symbol(in, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 68, 6)) + + constructor() { } + }, + instanceof: class { +>instanceof : Symbol(instanceof, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 71, 6)) + + constructor() { } + }, + new: class { +>new : Symbol(new, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 74, 6)) + + constructor() { } + }, + null: class { +>null : Symbol(null, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 77, 6)) + + constructor() { } + }, + return: class { +>return : Symbol(return, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 80, 6)) + + constructor() { } + }, + super: class { +>super : Symbol(super, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 83, 6)) + + constructor() { } + }, + switch: class { +>switch : Symbol(switch, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 86, 6)) + + constructor() { } + }, + this: class { +>this : Symbol(this, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 89, 6)) + + constructor() { } + }, + throw: class { +>throw : Symbol(throw, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 92, 6)) + + constructor() { } + }, + true: class { +>true : Symbol(true, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 95, 6)) + + constructor() { } + }, + try: class { +>try : Symbol(try, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 98, 6)) + + constructor() { } + }, + typeof: class { +>typeof : Symbol(typeof, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 101, 6)) + + constructor() { } + }, + var: class { +>var : Symbol(var, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 104, 6)) + + constructor() { } + }, + void: class { +>void : Symbol(void, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 107, 6)) + + constructor() { } + }, + while: class { +>while : Symbol(while, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 110, 6)) + + constructor() { } + }, + with: class { +>with : Symbol(with, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 113, 6)) + + constructor() { } + }, + implements: class { +>implements : Symbol(implements, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 116, 6)) + + constructor() { } + }, + interface: class { +>interface : Symbol(interface, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 119, 6)) + + constructor() { } + }, + let: class { +>let : Symbol(let, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 122, 6)) + + constructor() { } + }, + package: class { +>package : Symbol(package, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 125, 6)) + + constructor() { } + }, + private: class { +>private : Symbol(private, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 128, 6)) + + constructor() { } + }, + protected: class { +>protected : Symbol(protected, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 131, 6)) + + constructor() { } + }, + public: class { +>public : Symbol(public, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 134, 6)) + + constructor() { } + }, + static: class { +>static : Symbol(static, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 137, 6)) + + constructor() { } + }, + yield: class { +>yield : Symbol(yield, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 140, 6)) + + constructor() { } + }, + abstract: class { +>abstract : Symbol(abstract, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 143, 6)) + + constructor() { } + }, + as: class { +>as : Symbol(as, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 146, 6)) + + constructor() { } + }, + asserts: class { +>asserts : Symbol(asserts, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 149, 6)) + + constructor() { } + }, + any: class { +>any : Symbol(any, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 152, 6)) + + constructor() { } + }, + async: class { +>async : Symbol(async, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 155, 6)) + + constructor() { } + }, + await: class { +>await : Symbol(await, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 158, 6)) + + constructor() { } + }, + boolean: class { +>boolean : Symbol(boolean, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 161, 6)) + + constructor() { } + }, + constructor: class { +>constructor : Symbol(constructor, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 164, 6)) + + constructor() { } + }, + declare: class { +>declare : Symbol(declare, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 167, 6)) + + constructor() { } + }, + get: class { +>get : Symbol(get, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 170, 6)) + + constructor() { } + }, + infer: class { +>infer : Symbol(infer, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 173, 6)) + + constructor() { } + }, + is: class { +>is : Symbol(is, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 176, 6)) + + constructor() { } + }, + keyof: class { +>keyof : Symbol(keyof, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 179, 6)) + + constructor() { } + }, + module: class { +>module : Symbol(module, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 182, 6)) + + constructor() { } + }, + namespace: class { +>namespace : Symbol(namespace, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 185, 6)) + + constructor() { } + }, + never: class { +>never : Symbol(never, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 188, 6)) + + constructor() { } + }, + readonly: class { +>readonly : Symbol(readonly, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 191, 6)) + + constructor() { } + }, + require: class { +>require : Symbol(require, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 194, 6)) + + constructor() { } + }, + number: class { +>number : Symbol(number, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 197, 6)) + + constructor() { } + }, + object: class { +>object : Symbol(object, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 200, 6)) + + constructor() { } + }, + set: class { +>set : Symbol(set, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 203, 6)) + + constructor() { } + }, + string: class { +>string : Symbol(string, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 206, 6)) + + constructor() { } + }, + symbol: class { +>symbol : Symbol(symbol, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 209, 6)) + + constructor() { } + }, + type: class { +>type : Symbol(type, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 212, 6)) + + constructor() { } + }, + undefined: class { +>undefined : Symbol(undefined, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 215, 6)) + + constructor() { } + }, + unique: class { +>unique : Symbol(unique, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 218, 6)) + + constructor() { } + }, + unknown: class { +>unknown : Symbol(unknown, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 221, 6)) + + constructor() { } + }, + from: class { +>from : Symbol(from, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 224, 6)) + + constructor() { } + }, + global: class { +>global : Symbol(global, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 227, 6)) + + constructor() { } + }, + bigint: class { +>bigint : Symbol(bigint, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 230, 6)) + + constructor() { } + }, + of: class { +>of : Symbol(of, Decl(convertClassExpressionToFunctionFromObjectProperty2.ts, 233, 6)) + + constructor() { } + } +}) + diff --git a/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.types b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.types new file mode 100644 index 0000000000000..a0a8cc70109ed --- /dev/null +++ b/tests/baselines/reference/convertClassExpressionToFunctionFromObjectProperty2.types @@ -0,0 +1,477 @@ +=== tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty2.ts === +({ +>({ x: class { constructor() { } }, y: class { constructor() { } }, // keywords break: class { constructor() { } }, case: class { constructor() { } }, catch: class { constructor() { } }, class: class { constructor() { } }, const: class { constructor() { } }, continue: class { constructor() { } }, debugger: class { constructor() { } }, default: class { constructor() { } }, delete: class { constructor() { } }, do: class { constructor() { } }, else: class { constructor() { } }, enum: class { constructor() { } }, export: class { constructor() { } }, extends: class { constructor() { } }, false: class { constructor() { } }, finally: class { constructor() { } }, for: class { constructor() { } }, function: class { constructor() { } }, if: class { constructor() { } }, import: class { constructor() { } }, in: class { constructor() { } }, instanceof: class { constructor() { } }, new: class { constructor() { } }, null: class { constructor() { } }, return: class { constructor() { } }, super: class { constructor() { } }, switch: class { constructor() { } }, this: class { constructor() { } }, throw: class { constructor() { } }, true: class { constructor() { } }, try: class { constructor() { } }, typeof: class { constructor() { } }, var: class { constructor() { } }, void: class { constructor() { } }, while: class { constructor() { } }, with: class { constructor() { } }, implements: class { constructor() { } }, interface: class { constructor() { } }, let: class { constructor() { } }, package: class { constructor() { } }, private: class { constructor() { } }, protected: class { constructor() { } }, public: class { constructor() { } }, static: class { constructor() { } }, yield: class { constructor() { } }, abstract: class { constructor() { } }, as: class { constructor() { } }, asserts: class { constructor() { } }, any: class { constructor() { } }, async: class { constructor() { } }, await: class { constructor() { } }, boolean: class { constructor() { } }, constructor: class { constructor() { } }, declare: class { constructor() { } }, get: class { constructor() { } }, infer: class { constructor() { } }, is: class { constructor() { } }, keyof: class { constructor() { } }, module: class { constructor() { } }, namespace: class { constructor() { } }, never: class { constructor() { } }, readonly: class { constructor() { } }, require: class { constructor() { } }, number: class { constructor() { } }, object: class { constructor() { } }, set: class { constructor() { } }, string: class { constructor() { } }, symbol: class { constructor() { } }, type: class { constructor() { } }, undefined: class { constructor() { } }, unique: class { constructor() { } }, unknown: class { constructor() { } }, from: class { constructor() { } }, global: class { constructor() { } }, bigint: class { constructor() { } }, of: class { constructor() { } }}) : { x: typeof x; y: typeof y; break: typeof break; case: typeof case; catch: typeof catch; class: typeof class; const: typeof const; continue: typeof continue; debugger: typeof debugger; default: typeof default; delete: typeof delete; do: typeof do; else: typeof else; enum: typeof enum; export: typeof export; extends: typeof extends; false: typeof false; finally: typeof finally; for: typeof for; function: typeof function; if: typeof if; import: typeof import; in: typeof in; instanceof: typeof instanceof; new: typeof new; null: typeof null; return: typeof return; super: typeof super; switch: typeof switch; this: typeof this; throw: typeof throw; true: typeof true; try: typeof try; typeof: typeof typeof; var: typeof var; void: typeof void; while: typeof while; with: typeof with; implements: typeof implements; interface: typeof interface; let: typeof let; package: typeof package; private: typeof private; protected: typeof protected; public: typeof public; static: typeof static; yield: typeof yield; abstract: typeof abstract; as: typeof as; asserts: typeof asserts; any: typeof any; async: typeof async; await: typeof await; boolean: typeof boolean; constructor: typeof constructor; declare: typeof declare; get: typeof get; infer: typeof infer; is: typeof is; keyof: typeof keyof; module: typeof module; namespace: typeof namespace; never: typeof never; readonly: typeof readonly; require: typeof require; number: typeof number; object: typeof object; set: typeof set; string: typeof string; symbol: typeof symbol; type: typeof type; undefined: typeof undefined; unique: typeof unique; unknown: typeof unknown; from: typeof from; global: typeof global; bigint: typeof bigint; of: typeof of; } +>{ x: class { constructor() { } }, y: class { constructor() { } }, // keywords break: class { constructor() { } }, case: class { constructor() { } }, catch: class { constructor() { } }, class: class { constructor() { } }, const: class { constructor() { } }, continue: class { constructor() { } }, debugger: class { constructor() { } }, default: class { constructor() { } }, delete: class { constructor() { } }, do: class { constructor() { } }, else: class { constructor() { } }, enum: class { constructor() { } }, export: class { constructor() { } }, extends: class { constructor() { } }, false: class { constructor() { } }, finally: class { constructor() { } }, for: class { constructor() { } }, function: class { constructor() { } }, if: class { constructor() { } }, import: class { constructor() { } }, in: class { constructor() { } }, instanceof: class { constructor() { } }, new: class { constructor() { } }, null: class { constructor() { } }, return: class { constructor() { } }, super: class { constructor() { } }, switch: class { constructor() { } }, this: class { constructor() { } }, throw: class { constructor() { } }, true: class { constructor() { } }, try: class { constructor() { } }, typeof: class { constructor() { } }, var: class { constructor() { } }, void: class { constructor() { } }, while: class { constructor() { } }, with: class { constructor() { } }, implements: class { constructor() { } }, interface: class { constructor() { } }, let: class { constructor() { } }, package: class { constructor() { } }, private: class { constructor() { } }, protected: class { constructor() { } }, public: class { constructor() { } }, static: class { constructor() { } }, yield: class { constructor() { } }, abstract: class { constructor() { } }, as: class { constructor() { } }, asserts: class { constructor() { } }, any: class { constructor() { } }, async: class { constructor() { } }, await: class { constructor() { } }, boolean: class { constructor() { } }, constructor: class { constructor() { } }, declare: class { constructor() { } }, get: class { constructor() { } }, infer: class { constructor() { } }, is: class { constructor() { } }, keyof: class { constructor() { } }, module: class { constructor() { } }, namespace: class { constructor() { } }, never: class { constructor() { } }, readonly: class { constructor() { } }, require: class { constructor() { } }, number: class { constructor() { } }, object: class { constructor() { } }, set: class { constructor() { } }, string: class { constructor() { } }, symbol: class { constructor() { } }, type: class { constructor() { } }, undefined: class { constructor() { } }, unique: class { constructor() { } }, unknown: class { constructor() { } }, from: class { constructor() { } }, global: class { constructor() { } }, bigint: class { constructor() { } }, of: class { constructor() { } }} : { x: typeof x; y: typeof y; break: typeof break; case: typeof case; catch: typeof catch; class: typeof class; const: typeof const; continue: typeof continue; debugger: typeof debugger; default: typeof default; delete: typeof delete; do: typeof do; else: typeof else; enum: typeof enum; export: typeof export; extends: typeof extends; false: typeof false; finally: typeof finally; for: typeof for; function: typeof function; if: typeof if; import: typeof import; in: typeof in; instanceof: typeof instanceof; new: typeof new; null: typeof null; return: typeof return; super: typeof super; switch: typeof switch; this: typeof this; throw: typeof throw; true: typeof true; try: typeof try; typeof: typeof typeof; var: typeof var; void: typeof void; while: typeof while; with: typeof with; implements: typeof implements; interface: typeof interface; let: typeof let; package: typeof package; private: typeof private; protected: typeof protected; public: typeof public; static: typeof static; yield: typeof yield; abstract: typeof abstract; as: typeof as; asserts: typeof asserts; any: typeof any; async: typeof async; await: typeof await; boolean: typeof boolean; constructor: typeof constructor; declare: typeof declare; get: typeof get; infer: typeof infer; is: typeof is; keyof: typeof keyof; module: typeof module; namespace: typeof namespace; never: typeof never; readonly: typeof readonly; require: typeof require; number: typeof number; object: typeof object; set: typeof set; string: typeof string; symbol: typeof symbol; type: typeof type; undefined: typeof undefined; unique: typeof unique; unknown: typeof unknown; from: typeof from; global: typeof global; bigint: typeof bigint; of: typeof of; } + + x: class { +>x : typeof x +>class { constructor() { } } : typeof x + + constructor() { } + }, + y: class { +>y : typeof y +>class { constructor() { } } : typeof y + + constructor() { } + }, + + // keywords + break: class { +>break : typeof break +>class { constructor() { } } : typeof break + + constructor() { } + }, + case: class { +>case : typeof case +>class { constructor() { } } : typeof case + + constructor() { } + }, + catch: class { +>catch : typeof catch +>class { constructor() { } } : typeof catch + + constructor() { } + }, + class: class { +>class : typeof class +>class { constructor() { } } : typeof class + + constructor() { } + }, + const: class { +>const : typeof const +>class { constructor() { } } : typeof const + + constructor() { } + }, + continue: class { +>continue : typeof continue +>class { constructor() { } } : typeof continue + + constructor() { } + }, + debugger: class { +>debugger : typeof debugger +>class { constructor() { } } : typeof debugger + + constructor() { } + }, + default: class { +>default : typeof default +>class { constructor() { } } : typeof default + + constructor() { } + }, + delete: class { +>delete : typeof delete +>class { constructor() { } } : typeof delete + + constructor() { } + }, + do: class { +>do : typeof do +>class { constructor() { } } : typeof do + + constructor() { } + }, + else: class { +>else : typeof else +>class { constructor() { } } : typeof else + + constructor() { } + }, + enum: class { +>enum : typeof enum +>class { constructor() { } } : typeof enum + + constructor() { } + }, + export: class { +>export : typeof export +>class { constructor() { } } : typeof export + + constructor() { } + }, + extends: class { +>extends : typeof extends +>class { constructor() { } } : typeof extends + + constructor() { } + }, + false: class { +>false : typeof false +>class { constructor() { } } : typeof false + + constructor() { } + }, + finally: class { +>finally : typeof finally +>class { constructor() { } } : typeof finally + + constructor() { } + }, + for: class { +>for : typeof for +>class { constructor() { } } : typeof for + + constructor() { } + }, + function: class { +>function : typeof function +>class { constructor() { } } : typeof function + + constructor() { } + }, + if: class { +>if : typeof if +>class { constructor() { } } : typeof if + + constructor() { } + }, + import: class { +>import : typeof import +>class { constructor() { } } : typeof import + + constructor() { } + }, + in: class { +>in : typeof in +>class { constructor() { } } : typeof in + + constructor() { } + }, + instanceof: class { +>instanceof : typeof instanceof +>class { constructor() { } } : typeof instanceof + + constructor() { } + }, + new: class { +>new : typeof new +>class { constructor() { } } : typeof new + + constructor() { } + }, + null: class { +>null : typeof null +>class { constructor() { } } : typeof null + + constructor() { } + }, + return: class { +>return : typeof return +>class { constructor() { } } : typeof return + + constructor() { } + }, + super: class { +>super : typeof super +>class { constructor() { } } : typeof super + + constructor() { } + }, + switch: class { +>switch : typeof switch +>class { constructor() { } } : typeof switch + + constructor() { } + }, + this: class { +>this : typeof this +>class { constructor() { } } : typeof this + + constructor() { } + }, + throw: class { +>throw : typeof throw +>class { constructor() { } } : typeof throw + + constructor() { } + }, + true: class { +>true : typeof true +>class { constructor() { } } : typeof true + + constructor() { } + }, + try: class { +>try : typeof try +>class { constructor() { } } : typeof try + + constructor() { } + }, + typeof: class { +>typeof : typeof typeof +>class { constructor() { } } : typeof typeof + + constructor() { } + }, + var: class { +>var : typeof var +>class { constructor() { } } : typeof var + + constructor() { } + }, + void: class { +>void : typeof void +>class { constructor() { } } : typeof void + + constructor() { } + }, + while: class { +>while : typeof while +>class { constructor() { } } : typeof while + + constructor() { } + }, + with: class { +>with : typeof with +>class { constructor() { } } : typeof with + + constructor() { } + }, + implements: class { +>implements : typeof implements +>class { constructor() { } } : typeof implements + + constructor() { } + }, + interface: class { +>interface : typeof interface +>class { constructor() { } } : typeof interface + + constructor() { } + }, + let: class { +>let : typeof let +>class { constructor() { } } : typeof let + + constructor() { } + }, + package: class { +>package : typeof package +>class { constructor() { } } : typeof package + + constructor() { } + }, + private: class { +>private : typeof private +>class { constructor() { } } : typeof private + + constructor() { } + }, + protected: class { +>protected : typeof protected +>class { constructor() { } } : typeof protected + + constructor() { } + }, + public: class { +>public : typeof public +>class { constructor() { } } : typeof public + + constructor() { } + }, + static: class { +>static : typeof static +>class { constructor() { } } : typeof static + + constructor() { } + }, + yield: class { +>yield : typeof yield +>class { constructor() { } } : typeof yield + + constructor() { } + }, + abstract: class { +>abstract : typeof abstract +>class { constructor() { } } : typeof abstract + + constructor() { } + }, + as: class { +>as : typeof as +>class { constructor() { } } : typeof as + + constructor() { } + }, + asserts: class { +>asserts : typeof asserts +>class { constructor() { } } : typeof asserts + + constructor() { } + }, + any: class { +>any : typeof any +>class { constructor() { } } : typeof any + + constructor() { } + }, + async: class { +>async : typeof async +>class { constructor() { } } : typeof async + + constructor() { } + }, + await: class { +>await : typeof await +>class { constructor() { } } : typeof await + + constructor() { } + }, + boolean: class { +>boolean : typeof boolean +>class { constructor() { } } : typeof boolean + + constructor() { } + }, + constructor: class { +>constructor : typeof constructor +>class { constructor() { } } : typeof constructor + + constructor() { } + }, + declare: class { +>declare : typeof declare +>class { constructor() { } } : typeof declare + + constructor() { } + }, + get: class { +>get : typeof get +>class { constructor() { } } : typeof get + + constructor() { } + }, + infer: class { +>infer : typeof infer +>class { constructor() { } } : typeof infer + + constructor() { } + }, + is: class { +>is : typeof is +>class { constructor() { } } : typeof is + + constructor() { } + }, + keyof: class { +>keyof : typeof keyof +>class { constructor() { } } : typeof keyof + + constructor() { } + }, + module: class { +>module : typeof module +>class { constructor() { } } : typeof module + + constructor() { } + }, + namespace: class { +>namespace : typeof namespace +>class { constructor() { } } : typeof namespace + + constructor() { } + }, + never: class { +>never : typeof never +>class { constructor() { } } : typeof never + + constructor() { } + }, + readonly: class { +>readonly : typeof readonly +>class { constructor() { } } : typeof readonly + + constructor() { } + }, + require: class { +>require : typeof require +>class { constructor() { } } : typeof require + + constructor() { } + }, + number: class { +>number : typeof number +>class { constructor() { } } : typeof number + + constructor() { } + }, + object: class { +>object : typeof object +>class { constructor() { } } : typeof object + + constructor() { } + }, + set: class { +>set : typeof set +>class { constructor() { } } : typeof set + + constructor() { } + }, + string: class { +>string : typeof string +>class { constructor() { } } : typeof string + + constructor() { } + }, + symbol: class { +>symbol : typeof symbol +>class { constructor() { } } : typeof symbol + + constructor() { } + }, + type: class { +>type : typeof type +>class { constructor() { } } : typeof type + + constructor() { } + }, + undefined: class { +>undefined : typeof undefined +>class { constructor() { } } : typeof undefined + + constructor() { } + }, + unique: class { +>unique : typeof unique +>class { constructor() { } } : typeof unique + + constructor() { } + }, + unknown: class { +>unknown : typeof unknown +>class { constructor() { } } : typeof unknown + + constructor() { } + }, + from: class { +>from : typeof from +>class { constructor() { } } : typeof from + + constructor() { } + }, + global: class { +>global : typeof global +>class { constructor() { } } : typeof global + + constructor() { } + }, + bigint: class { +>bigint : typeof bigint +>class { constructor() { } } : typeof bigint + + constructor() { } + }, + of: class { +>of : typeof of +>class { constructor() { } } : typeof of + + constructor() { } + } +}) + diff --git a/tests/baselines/reference/convertKeywordsYes.js b/tests/baselines/reference/convertKeywordsYes.js index 4605db05c6cfe..c05cd3301d568 100644 --- a/tests/baselines/reference/convertKeywordsYes.js +++ b/tests/baselines/reference/convertKeywordsYes.js @@ -506,19 +506,19 @@ var bigModule; return constructor; }()); var implements = /** @class */ (function () { - function implements() { + function implements_1() { } - return implements; + return implements_1; }()); var interface = /** @class */ (function () { - function interface() { + function interface_1() { } - return interface; + return interface_1; }()); var let = /** @class */ (function () { - function let() { + function let_1() { } - return let; + return let_1; }()); var module = /** @class */ (function () { function module() { @@ -526,24 +526,24 @@ var bigModule; return module; }()); var package = /** @class */ (function () { - function package() { + function package_1() { } - return package; + return package_1; }()); var private = /** @class */ (function () { - function private() { + function private_1() { } - return private; + return private_1; }()); var protected = /** @class */ (function () { - function protected() { + function protected_1() { } - return protected; + return protected_1; }()); var public = /** @class */ (function () { - function public() { + function public_1() { } - return public; + return public_1; }()); var set = /** @class */ (function () { function set() { @@ -551,9 +551,9 @@ var bigModule; return set; }()); var static = /** @class */ (function () { - function static() { + function static_1() { } - return static; + return static_1; }()); var get = /** @class */ (function () { function get() { @@ -561,9 +561,9 @@ var bigModule; return get; }()); var yield = /** @class */ (function () { - function yield() { + function yield_1() { } - return yield; + return yield_1; }()); var declare = /** @class */ (function () { function declare() { diff --git a/tests/baselines/reference/strictModeReservedWord.js b/tests/baselines/reference/strictModeReservedWord.js index 12c0c8feaa5e8..b5e7c24e831fb 100644 --- a/tests/baselines/reference/strictModeReservedWord.js +++ b/tests/baselines/reference/strictModeReservedWord.js @@ -55,10 +55,10 @@ function foo() { barn(function (private, public, package) { }); var myClass = /** @class */ (function (_super) { __extends(package, _super); - function package() { + function package_1() { return _super !== null && _super.apply(this, arguments) || this; } - return package; + return package_1; }(public)); var b; function foo(x) { } diff --git a/tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty1.ts b/tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty1.ts new file mode 100644 index 0000000000000..d2eb76eb9640c --- /dev/null +++ b/tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty1.ts @@ -0,0 +1,241 @@ +// @target: es5 + +const foo: any = {}; + +// properties +foo.x = class { + constructor () {} +} +foo.y = class { + constructor () {} +} + +// keywords +foo.break = class { + constructor () {} +} +foo.case = class { + constructor () {} +} +foo.catch = class { + constructor () {} +} +foo.class = class { + constructor () {} +} +foo.const = class { + constructor () {} +} +foo.continue = class { + constructor () {} +} +foo.debugger = class { + constructor () {} +} +foo.default = class { + constructor () {} +} +foo.delete = class { + constructor () {} +} +foo.do = class { + constructor () {} +} +foo.else = class { + constructor () {} +} +foo.enum = class { + constructor () {} +} +foo.export = class { + constructor () {} +} +foo.extends = class { + constructor () {} +} +foo.false = class { + constructor () {} +} +foo.finally = class { + constructor () {} +} +foo.for = class { + constructor () {} +} +foo.function = class { + constructor () {} +} +foo.if = class { + constructor () {} +} +foo.import = class { + constructor () {} +} +foo.in = class { + constructor () {} +} +foo.instanceof = class { + constructor () {} +} +foo.new = class { + constructor () {} +} +foo.null = class { + constructor () {} +} +foo.return = class { + constructor () {} +} +foo.super = class { + constructor () {} +} +foo.switch = class { + constructor () {} +} +foo.this = class { + constructor () {} +} +foo.throw = class { + constructor () {} +} +foo.true = class { + constructor () {} +} +foo.try = class { + constructor () {} +} +foo.typeof = class { + constructor () {} +} +foo.var = class { + constructor () {} +} +foo.void = class { + constructor () {} +} +foo.while = class { + constructor () {} +} +foo.with = class { + constructor () {} +} +foo.implements = class { + constructor () {} +} +foo.interface = class { + constructor () {} +} +foo.let = class { + constructor () {} +} +foo.package = class { + constructor () {} +} +foo.private = class { + constructor () {} +} +foo.protected = class { + constructor () {} +} +foo.public = class { + constructor () {} +} +foo.static = class { + constructor () {} +} +foo.yield = class { + constructor () {} +} +foo.abstract = class { + constructor () {} +} +foo.as = class { + constructor () {} +} +foo.asserts = class { + constructor () {} +} +foo.any = class { + constructor () {} +} +foo.async = class { + constructor () {} +} +foo.await = class { + constructor () {} +} +foo.boolean = class { + constructor () {} +} +foo.constructor = class { + constructor () {} +} +foo.declare = class { + constructor () {} +} +foo.get = class { + constructor () {} +} +foo.infer = class { + constructor () {} +} +foo.is = class { + constructor () {} +} +foo.keyof = class { + constructor () {} +} +foo.module = class { + constructor () {} +} +foo.namespace = class { + constructor () {} +} +foo.never = class { + constructor () {} +} +foo.readonly = class { + constructor () {} +} +foo.require = class { + constructor () {} +} +foo.number = class { + constructor () {} +} +foo.object = class { + constructor () {} +} +foo.set = class { + constructor () {} +} +foo.string = class { + constructor () {} +} +foo.symbol = class { + constructor () {} +} +foo.type = class { + constructor () {} +} +foo.undefined = class { + constructor () {} +} +foo.unique = class { + constructor () {} +} +foo.unknown = class { + constructor () {} +} +foo.from = class { + constructor () {} +} +foo.global = class { + constructor () {} +} +foo.bigint = class { + constructor () {} +} +foo.of = class { + constructor () {} +} diff --git a/tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty2.ts b/tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty2.ts new file mode 100644 index 0000000000000..3d1c4b34bdb83 --- /dev/null +++ b/tests/cases/compiler/convertClassExpressionToFunctionFromObjectProperty2.ts @@ -0,0 +1,240 @@ +// @target: es5 + +({ + x: class { + constructor() { } + }, + y: class { + constructor() { } + }, + + // keywords + break: class { + constructor() { } + }, + case: class { + constructor() { } + }, + catch: class { + constructor() { } + }, + class: class { + constructor() { } + }, + const: class { + constructor() { } + }, + continue: class { + constructor() { } + }, + debugger: class { + constructor() { } + }, + default: class { + constructor() { } + }, + delete: class { + constructor() { } + }, + do: class { + constructor() { } + }, + else: class { + constructor() { } + }, + enum: class { + constructor() { } + }, + export: class { + constructor() { } + }, + extends: class { + constructor() { } + }, + false: class { + constructor() { } + }, + finally: class { + constructor() { } + }, + for: class { + constructor() { } + }, + function: class { + constructor() { } + }, + if: class { + constructor() { } + }, + import: class { + constructor() { } + }, + in: class { + constructor() { } + }, + instanceof: class { + constructor() { } + }, + new: class { + constructor() { } + }, + null: class { + constructor() { } + }, + return: class { + constructor() { } + }, + super: class { + constructor() { } + }, + switch: class { + constructor() { } + }, + this: class { + constructor() { } + }, + throw: class { + constructor() { } + }, + true: class { + constructor() { } + }, + try: class { + constructor() { } + }, + typeof: class { + constructor() { } + }, + var: class { + constructor() { } + }, + void: class { + constructor() { } + }, + while: class { + constructor() { } + }, + with: class { + constructor() { } + }, + implements: class { + constructor() { } + }, + interface: class { + constructor() { } + }, + let: class { + constructor() { } + }, + package: class { + constructor() { } + }, + private: class { + constructor() { } + }, + protected: class { + constructor() { } + }, + public: class { + constructor() { } + }, + static: class { + constructor() { } + }, + yield: class { + constructor() { } + }, + abstract: class { + constructor() { } + }, + as: class { + constructor() { } + }, + asserts: class { + constructor() { } + }, + any: class { + constructor() { } + }, + async: class { + constructor() { } + }, + await: class { + constructor() { } + }, + boolean: class { + constructor() { } + }, + constructor: class { + constructor() { } + }, + declare: class { + constructor() { } + }, + get: class { + constructor() { } + }, + infer: class { + constructor() { } + }, + is: class { + constructor() { } + }, + keyof: class { + constructor() { } + }, + module: class { + constructor() { } + }, + namespace: class { + constructor() { } + }, + never: class { + constructor() { } + }, + readonly: class { + constructor() { } + }, + require: class { + constructor() { } + }, + number: class { + constructor() { } + }, + object: class { + constructor() { } + }, + set: class { + constructor() { } + }, + string: class { + constructor() { } + }, + symbol: class { + constructor() { } + }, + type: class { + constructor() { } + }, + undefined: class { + constructor() { } + }, + unique: class { + constructor() { } + }, + unknown: class { + constructor() { } + }, + from: class { + constructor() { } + }, + global: class { + constructor() { } + }, + bigint: class { + constructor() { } + }, + of: class { + constructor() { } + } +})