Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorator type metadata #2589

Merged
merged 18 commits into from
Apr 6, 2015
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
271 changes: 266 additions & 5 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ module ts {
shortName: "w",
type: "boolean",
description: Diagnostics.Watch_input_files,
},
{
name: "emitDecoratorMetadata",
type: "boolean",
experimental: true
}
];

Expand Down
395 changes: 258 additions & 137 deletions src/compiler/emitter.ts

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,9 @@ module ts {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
}

export const enum SymbolFlags {
Expand Down Expand Up @@ -1380,6 +1383,7 @@ module ts {
EnumValuesComputed = 0x00000080,
BlockScopedBindingInLoop = 0x00000100,
EmitDecorate = 0x00000200, // Emit __decorate
EmitParam = 0x00000400, // Emit __param helper for decorators
}

export interface NodeLinks {
Expand Down Expand Up @@ -1605,6 +1609,7 @@ module ts {
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
emitDecoratorMetadata?: boolean;
/* @internal */ stripInternal?: boolean;
[option: string]: string | number | boolean;
}
Expand Down
12 changes: 12 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,18 @@ module ts {
return false;
}

export function isAccessor(node: Node): boolean {
if (node) {
switch (node.kind) {
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return true;
}
}

return false;
}

export function isFunctionLike(node: Node): boolean {
if (node) {
switch (node.kind) {
Expand Down
36 changes: 18 additions & 18 deletions src/lib/es6.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3513,27 +3513,27 @@ interface ProxyHandler<T> {

interface ProxyConstructor {
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
new <T>(target: T, handeler: ProxyHandler<T>): T
new <T>(target: T, handler: ProxyHandler<T>): T
}
declare var Proxy: ProxyConstructor;

declare var Reflect: {
apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
construct(target: Function, argumentsList: ArrayLike<any>): any;
defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
deleteProperty(target: any, propertyKey: PropertyKey): boolean;
enumerate(target: any): IterableIterator<any>;
get(target: any, propertyKey: PropertyKey, receiver?: any): any;
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
getPrototypeOf(target: any): any;
has(target: any, propertyKey: string): boolean;
has(target: any, propertyKey: symbol): boolean;
isExtensible(target: any): boolean;
ownKeys(target: any): Array<PropertyKey>;
preventExtensions(target: any): boolean;
set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean;
setPrototypeOf(target: any, proto: any): boolean;
};
declare module Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>): any;
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
function enumerate(target: any): IterableIterator<any>;
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
function getPrototypeOf(target: any): any;
function has(target: any, propertyKey: string): boolean;
function has(target: any, propertyKey: symbol): boolean;
function isExtensible(target: any): boolean;
function ownKeys(target: any): Array<PropertyKey>;
function preventExtensions(target: any): boolean;
function set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean;
function setPrototypeOf(target: any, proto: any): boolean;
}

/**
* Represents the completion of an asynchronous operation
Expand Down
5 changes: 5 additions & 0 deletions tests/baselines/reference/APISample_compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,9 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
}
const enum SymbolFlags {
FunctionScopedVariable = 1,
Expand Down Expand Up @@ -1084,6 +1087,7 @@ declare module "typescript" {
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
EmitParam = 1024,
}
interface NodeLinks {
resolvedType?: Type;
Expand Down Expand Up @@ -1256,6 +1260,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
emitDecoratorMetadata?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
Expand Down
30 changes: 30 additions & 0 deletions tests/baselines/reference/APISample_compile.types
Original file line number Diff line number Diff line change
Expand Up @@ -3189,6 +3189,30 @@ declare module "typescript" {
>getBlockScopedVariableId : (node: Identifier) => number
>node : Identifier
>Identifier : Identifier

serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
>serializeTypeOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => string | string[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node

serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
>serializeParameterTypesOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => (string | string[])[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node

serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
>serializeReturnTypeOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => string | string[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node
}
const enum SymbolFlags {
>SymbolFlags : SymbolFlags
Expand Down Expand Up @@ -3505,6 +3529,9 @@ declare module "typescript" {

EmitDecorate = 512,
>EmitDecorate : NodeCheckFlags

EmitParam = 1024,
>EmitParam : NodeCheckFlags
}
interface NodeLinks {
>NodeLinks : NodeLinks
Expand Down Expand Up @@ -4020,6 +4047,9 @@ declare module "typescript" {
separateCompilation?: boolean;
>separateCompilation : boolean

emitDecoratorMetadata?: boolean;
>emitDecoratorMetadata : boolean

[option: string]: string | number | boolean;
>option : string
}
Expand Down
5 changes: 5 additions & 0 deletions tests/baselines/reference/APISample_linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,9 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
}
const enum SymbolFlags {
FunctionScopedVariable = 1,
Expand Down Expand Up @@ -1115,6 +1118,7 @@ declare module "typescript" {
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
EmitParam = 1024,
}
interface NodeLinks {
resolvedType?: Type;
Expand Down Expand Up @@ -1287,6 +1291,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
emitDecoratorMetadata?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
Expand Down
30 changes: 30 additions & 0 deletions tests/baselines/reference/APISample_linter.types
Original file line number Diff line number Diff line change
Expand Up @@ -3335,6 +3335,30 @@ declare module "typescript" {
>getBlockScopedVariableId : (node: Identifier) => number
>node : Identifier
>Identifier : Identifier

serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
>serializeTypeOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => string | string[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node

serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
>serializeParameterTypesOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => (string | string[])[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node

serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
>serializeReturnTypeOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => string | string[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node
}
const enum SymbolFlags {
>SymbolFlags : SymbolFlags
Expand Down Expand Up @@ -3651,6 +3675,9 @@ declare module "typescript" {

EmitDecorate = 512,
>EmitDecorate : NodeCheckFlags

EmitParam = 1024,
>EmitParam : NodeCheckFlags
}
interface NodeLinks {
>NodeLinks : NodeLinks
Expand Down Expand Up @@ -4166,6 +4193,9 @@ declare module "typescript" {
separateCompilation?: boolean;
>separateCompilation : boolean

emitDecoratorMetadata?: boolean;
>emitDecoratorMetadata : boolean

[option: string]: string | number | boolean;
>option : string
}
Expand Down
30 changes: 30 additions & 0 deletions tests/baselines/reference/APISample_linter.types.pull
Original file line number Diff line number Diff line change
Expand Up @@ -3335,6 +3335,30 @@ declare module "typescript" {
>getBlockScopedVariableId : (node: Identifier) => number
>node : Identifier
>Identifier : Identifier

serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
>serializeTypeOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => string | string[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node

serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
>serializeParameterTypesOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => (string | string[])[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node

serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
>serializeReturnTypeOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => string | string[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node
}
const enum SymbolFlags {
>SymbolFlags : SymbolFlags
Expand Down Expand Up @@ -3651,6 +3675,9 @@ declare module "typescript" {

EmitDecorate = 512,
>EmitDecorate : NodeCheckFlags

EmitParam = 1024,
>EmitParam : NodeCheckFlags
}
interface NodeLinks {
>NodeLinks : NodeLinks
Expand Down Expand Up @@ -4166,6 +4193,9 @@ declare module "typescript" {
separateCompilation?: boolean;
>separateCompilation : boolean

emitDecoratorMetadata?: boolean;
>emitDecoratorMetadata : boolean

[option: string]: string | number | boolean;
>option : string
}
Expand Down
5 changes: 5 additions & 0 deletions tests/baselines/reference/APISample_transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,9 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
}
const enum SymbolFlags {
FunctionScopedVariable = 1,
Expand Down Expand Up @@ -1116,6 +1119,7 @@ declare module "typescript" {
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
EmitParam = 1024,
}
interface NodeLinks {
resolvedType?: Type;
Expand Down Expand Up @@ -1288,6 +1292,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
emitDecoratorMetadata?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
Expand Down
30 changes: 30 additions & 0 deletions tests/baselines/reference/APISample_transform.types
Original file line number Diff line number Diff line change
Expand Up @@ -3285,6 +3285,30 @@ declare module "typescript" {
>getBlockScopedVariableId : (node: Identifier) => number
>node : Identifier
>Identifier : Identifier

serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
>serializeTypeOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => string | string[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node

serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
>serializeParameterTypesOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => (string | string[])[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node

serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
>serializeReturnTypeOfNode : (node: Node, getGeneratedNameForNode: (Node: Node) => string) => string | string[]
>node : Node
>Node : Node
>getGeneratedNameForNode : (Node: Node) => string
>Node : Node
>Node : Node
}
const enum SymbolFlags {
>SymbolFlags : SymbolFlags
Expand Down Expand Up @@ -3601,6 +3625,9 @@ declare module "typescript" {

EmitDecorate = 512,
>EmitDecorate : NodeCheckFlags

EmitParam = 1024,
>EmitParam : NodeCheckFlags
}
interface NodeLinks {
>NodeLinks : NodeLinks
Expand Down Expand Up @@ -4116,6 +4143,9 @@ declare module "typescript" {
separateCompilation?: boolean;
>separateCompilation : boolean

emitDecoratorMetadata?: boolean;
>emitDecoratorMetadata : boolean

[option: string]: string | number | boolean;
>option : string
}
Expand Down
Loading