Added experimentalDecorators flag

This commit is contained in:
Ron Buckton 2015-06-01 15:01:24 -07:00
parent 711886e099
commit 62ba36908b
49 changed files with 86 additions and 6 deletions

View file

@ -8942,6 +8942,10 @@ module ts {
if (!nodeCanBeDecorated(node)) {
return;
}
if (!compilerOptions.experimentalDecorators) {
error(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning);
}
if (compilerOptions.emitDecoratorMetadata) {
// we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator.

View file

@ -188,10 +188,16 @@ module ts {
type: "boolean",
description: Diagnostics.Watch_input_files,
},
{
name: "experimentalDecorators",
type: "boolean",
description: Diagnostics.Enables_experimental_support_for_ES7_decorators
},
{
name: "emitDecoratorMetadata",
type: "boolean",
experimental: true
experimental: true,
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
}
];

View file

@ -174,6 +174,7 @@ module ts {
Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." },
Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@ -507,6 +508,9 @@ module ts {
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." },
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },

View file

@ -683,6 +683,10 @@
"category": "Error",
"code": 1218
},
"Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": {
"category": "Error",
"code": 1219
},
"Duplicate identifier '{0}'.": {
"category": "Error",
@ -2018,7 +2022,18 @@
"category": "Error",
"code": 6062
},
"Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": {
"category": "Error",
"code": 6064
},
"Enables experimental support for ES7 decorators.": {
"category": "Message",
"code": 6065
},
"Enables experimental support for emitting type metadata for decorators.": {
"category": "Message",
"code": 6066
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",

View file

@ -635,6 +635,11 @@ module ts {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration));
}
}
if (options.emitDecoratorMetadata &&
!options.experimentalDecorators) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified));
}
}
}
}

View file

@ -1677,6 +1677,7 @@ module ts {
version?: boolean;
watch?: boolean;
isolatedModules?: boolean;
experimentalDecorators?: boolean;
emitDecoratorMetadata?: boolean;
/* @internal */ stripInternal?: boolean;
[option: string]: string | number | boolean;

View file

@ -998,6 +998,10 @@ module Harness {
options.target = <any>setting.value;
}
break;
case 'experimentaldecorators':
options.experimentalDecorators = setting.value === 'true';
break;
case 'emitdecoratormetadata':
options.emitDecoratorMetadata = setting.value === 'true';
@ -1510,7 +1514,7 @@ module Harness {
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
"isolatedmodules", "inlinesourcemap", "maproot", "sourceroot",
"inlinesources", "emitdecoratormetadata"];
"inlinesources", "emitdecoratormetadata", "experimentaldecorators"];
function extractCompilerSettings(content: string): CompilerSetting[] {

View file

@ -1 +1,2 @@
// @experimentaldecorators: true
var v = @decorate class C { static p = 1 };

View file

@ -1,4 +1,5 @@
// @noemithelpers: true
// @experimentaldecorators: true
// @emitdecoratormetadata: true
// @target: es5

View file

@ -1,5 +1,6 @@
// @sourcemap: true
// @target: es5
// @experimentaldecorators: true
declare function ClassDecorator1(target: Function): void;
declare function ClassDecorator2(x: number): (target: Function) => void;
declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void;

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
class C {

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
class C {

View file

@ -1,4 +1,5 @@
// @target: es6
// @experimentaldecorators: true
// @Filename: decorated.ts
function decorate() { }

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
// from #2971
function func(s: string): void {

View file

@ -1,5 +1,6 @@
// @target:es5
// @module:commonjs
// @experimentaldecorators: true
// @filename: a.ts
// from #3108

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec<T>(target: T): T;
@dec

View file

@ -1,5 +1,6 @@
// @target:es5
// @module: commonjs
// @experimentaldecorators: true
declare function dec<T>(target: T): T;
@dec

View file

@ -1,5 +1,6 @@
// @target:es5
// @module: commonjs
// @experimentaldecorators: true
declare function dec<T>(target: T): T;
export

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec(): <T>(target: T) => T;
@dec()

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec(): <T>(target: T) => T;
@dec()

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec(): (target: Function, paramIndex: number) => void;
@dec()

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec(target: Function, paramIndex: number): void;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
module M {
class C {
decorator(target: Object, key: string): void { }

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
module M {
class S {
decorator(target: Object, key: string): void { }

View file

@ -1,4 +1,5 @@
// @target: ES6
// @experimentaldecorators: true
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES6
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES6
// @experimentaldecorators: true
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES6
// @experimentaldecorators: true
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES6
// @experimentaldecorators: true
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec<T>(target: T): T;
class C {

View file

@ -1,4 +1,5 @@
// @target:es5
// @experimentaldecorators: true
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec(target: any, propertyKey: string): void;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec(): <T>(target: any, propertyKey: string) => void;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec(): <T>(target: any, propertyKey: string) => void;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec(target: any, propertyKey: string): void;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec(target: any, propertyKey: string): void;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec(target: Function): void;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @experimentaldecorators: true
declare function dec(target: Function, propertyKey: string | symbol, paramIndex: number): void;
class C {

View file

@ -1,4 +1,5 @@
// @target: ES5
// @target: ES5
// @experimentaldecorators: true
// @noLib: true
// @Filename: a.ts
@ -11,8 +12,7 @@ interface Function { }
interface RegExp { }
interface IArguments { }
// @Filename: b.ts
/// <reference path="a.ts" />
// @Filename: b.ts
declare var dec: any;
@dec