demo/typescript.js
function getEffectiveDecoratorSecondArgumentType(node) {
            // The second argument to a decorator is its `propertyKey`
            if (node.kind === 214 /* ClassDeclaration */) {
                ts.Debug.fail("Class decorators should not have a second synthetic argument.");
                return unknownType;
            }
            if (node.kind === 138 /* Parameter */) {
                node = node.parent;
                if (node.kind === 144 /* Constructor */) {
                    // For a constructor parameter decorator, the `propertyKey` will be `undefined`.
                    return anyType;
                }
            }
            if (node.kind === 141 /* PropertyDeclaration */ ||
                node.kind === 143 /* MethodDeclaration */ ||
                node.kind === 145 /* GetAccessor */ ||
                node.kind === 146 /* SetAccessor */) {
                // The `propertyKey` for a property or method decorator will be a
                // string literal type if the member name is an identifier, number, or string;
                // otherwise, if the member name is a computed property name it will
                // be either string or symbol.
                var element = node;
                switch (element.name.kind) {
                    case 69 /* Identifier */:
                    case 8 /* NumericLiteral */:
                    case 9 /* StringLiteral */:
                        return getStringLiteralType(element.name);
                    case 136 /* ComputedPropertyName */:
                        var nameType = checkComputedPropertyName(element.name);
                        if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) {
                            return nameType;
                        }
                        else {
                            return stringType;
                        }
                    default:
                        ts.Debug.fail("Unsupported property name.");
                        return unknownType;
                }
            }
            ts.Debug.fail("Unsupported decorator target.");
            return unknownType;
        }
function getEffectiveDecoratorSecondArgumentType(node) {
            // The second argument to a decorator is its `propertyKey`
            if (node.kind === 214 /* ClassDeclaration */) {
                ts.Debug.fail("Class decorators should not have a second synthetic argument.");
                return unknownType;
            }
            if (node.kind === 138 /* Parameter */) {
                node = node.parent;
                if (node.kind === 144 /* Constructor */) {
                    // For a constructor parameter decorator, the `propertyKey` will be `undefined`.
                    return anyType;
                }
            }
            if (node.kind === 141 /* PropertyDeclaration */ ||
                node.kind === 143 /* MethodDeclaration */ ||
                node.kind === 145 /* GetAccessor */ ||
                node.kind === 146 /* SetAccessor */) {
                // The `propertyKey` for a property or method decorator will be a
                // string literal type if the member name is an identifier, number, or string;
                // otherwise, if the member name is a computed property name it will
                // be either string or symbol.
                var element = node;
                switch (element.name.kind) {
                    case 69 /* Identifier */:
                    case 8 /* NumericLiteral */:
                    case 9 /* StringLiteral */:
                        return getStringLiteralType(element.name);
                    case 136 /* ComputedPropertyName */:
                        var nameType = checkComputedPropertyName(element.name);
                        if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) {
                            return nameType;
                        }
                        else {
                            return stringType;
                        }
                    default:
                        ts.Debug.fail("Unsupported property name.");
                        return unknownType;
                }
            }
            ts.Debug.fail("Unsupported decorator target.");
            return unknownType;
        }
Returns the effective type for the second argument to a decorator.
If 'node' is a parameter, its effective argument type is one of the following:
If 'node.parent' is a constructor, the effective argument type is 'any', as we
will emit `undefined`.
If 'node.parent' is a member with an identifier, numeric, or string literal name,
the effective argument type will be a string literal type for the member name.
If 'node.parent' is a computed property name, the effective argument type will
either be a symbol type or the string type.
If 'node' is a member with an identifier, numeric, or string literal name, the
effective argument type will be a string literal type for the member name.
If 'node' is a computed property name, the effective argument type will either
be a symbol type or the string type.
A class decorator does not have a second argument type.