Merge branch 'master' into layering
Conflicts: src/compiler/parser.ts
This commit is contained in:
commit
67b2f13cce
|
@ -3342,7 +3342,7 @@ module ts {
|
|||
}
|
||||
|
||||
function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration) {
|
||||
return !node.typeParameters && !forEach(node.parameters, p => p.type);
|
||||
return !node.typeParameters && node.parameters.length && !forEach(node.parameters, p => p.type);
|
||||
}
|
||||
|
||||
function getTypeWithoutConstructors(type: Type): Type {
|
||||
|
|
|
@ -54,6 +54,11 @@ module ts {
|
|||
paramType: Diagnostics.KIND,
|
||||
error: Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd
|
||||
},
|
||||
{
|
||||
name: "noEmit",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_emit_outputs,
|
||||
},
|
||||
{
|
||||
name: "noEmitOnError",
|
||||
type: "boolean",
|
||||
|
|
|
@ -380,6 +380,8 @@ module ts {
|
|||
Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
|
||||
Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option mapRoot cannot be specified without specifying sourcemap option." },
|
||||
Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option sourceRoot cannot be specified without specifying sourcemap option." },
|
||||
Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option noEmit cannot be specified with option out or outDir." },
|
||||
Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option noEmit cannot be specified with option declaration." },
|
||||
Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
|
||||
Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
|
||||
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
|
||||
|
@ -389,6 +391,7 @@ module ts {
|
|||
Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." },
|
||||
Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6008, category: DiagnosticCategory.Message, key: "Do not emit outputs if any type checking errors were reported." },
|
||||
Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." },
|
||||
Do_not_emit_outputs: { code: 6010, category: DiagnosticCategory.Message, key: "Do not emit outputs." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
|
||||
Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" },
|
||||
Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." },
|
||||
|
|
|
@ -1616,6 +1616,14 @@
|
|||
"category": "Error",
|
||||
"code": 5039
|
||||
},
|
||||
"Option noEmit cannot be specified with option out or outDir.": {
|
||||
"category": "Error",
|
||||
"code": 5040
|
||||
},
|
||||
"Option noEmit cannot be specified with option declaration.": {
|
||||
"category": "Error",
|
||||
"code": 5041
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
|
@ -1652,6 +1660,10 @@
|
|||
"category": "Message",
|
||||
"code": 6009
|
||||
},
|
||||
"Do not emit outputs.": {
|
||||
"category": "Message",
|
||||
"code": 6010
|
||||
},
|
||||
"Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)": {
|
||||
"category": "Message",
|
||||
"code": 6015
|
||||
|
|
|
@ -88,6 +88,7 @@ module ts {
|
|||
verifyCompilerOptions();
|
||||
errors.sort(compareDiagnostics);
|
||||
|
||||
|
||||
var diagnosticsProducingTypeChecker: TypeChecker;
|
||||
var noDiagnosticsTypeChecker: TypeChecker;
|
||||
var emitHost: EmitHost;
|
||||
|
@ -145,9 +146,7 @@ module ts {
|
|||
function invokeEmitter(targetSourceFile?: SourceFile) {
|
||||
var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver();
|
||||
return emitFiles(resolver, getEmitHost(), targetSourceFile);
|
||||
}
|
||||
|
||||
function getSourceFile(filename: string) {
|
||||
} function getSourceFile(filename: string) {
|
||||
filename = host.getCanonicalFileName(filename);
|
||||
return hasProperty(filesByName, filename) ? filesByName[filename] : undefined;
|
||||
}
|
||||
|
@ -218,8 +217,13 @@ module ts {
|
|||
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
var file = filesByName[canonicalName] = host.getSourceFile(filename, options.target, hostErrorMessage => {
|
||||
errors.push(createFileDiagnostic(refFile, refStart, refLength,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
|
||||
if (refFile) {
|
||||
errors.push(createFileDiagnostic(refFile, refStart, refLength,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
|
||||
}
|
||||
});
|
||||
if (file) {
|
||||
seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib;
|
||||
|
@ -389,6 +393,16 @@ module ts {
|
|||
commonSourceDirectory += directorySeparator;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.noEmit) {
|
||||
if (options.out || options.outDir) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir));
|
||||
}
|
||||
|
||||
if (options.declaration) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -289,6 +289,9 @@ module ts {
|
|||
if (program.isEmitBlocked()) {
|
||||
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
|
||||
}
|
||||
else if (compilerOptions.noEmit) {
|
||||
exitStatus = EmitReturnStatus.Succeeded;
|
||||
}
|
||||
else {
|
||||
var emitStart = new Date().getTime();
|
||||
var emitOutput = program.emitFiles();
|
||||
|
|
|
@ -974,7 +974,7 @@ module ts {
|
|||
|
||||
// Return code used by getEmitOutput function to indicate status of the function
|
||||
export enum EmitReturnStatus {
|
||||
Succeeded = 0, // All outputs generated as requested (.js, .map, .d.ts), no errors reported
|
||||
Succeeded = 0, // All outputs generated if requested (.js, .map, .d.ts), no errors reported
|
||||
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, nothing generated
|
||||
JSGeneratedWithSemanticErrors = 2, // .js and .map generated with semantic errors
|
||||
DeclarationGenerationSkipped = 3, // .d.ts generation skipped because of semantic errors or declaration emitter specific errors; Output .js with semantic errors
|
||||
|
@ -1453,6 +1453,7 @@ module ts {
|
|||
locale?: string;
|
||||
mapRoot?: string;
|
||||
module?: ModuleKind;
|
||||
noEmit?: boolean;
|
||||
noEmitOnError?: boolean;
|
||||
noErrorTruncation?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'.
|
||||
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (2 errors) ====
|
||||
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (1 errors) ====
|
||||
var f10: <T>(x: T, b: () => (a: T) => void, y: T) => T;
|
||||
f10('', () => a => a.foo, ''); // a is string
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'string'.
|
||||
var r9 = f10('', () => (a => a.foo), 1); // error
|
||||
~~~
|
||||
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.
|
||||
var r9 = f10('', () => (a => a.foo), 1); // error
|
|
@ -0,0 +1,17 @@
|
|||
//// [inferenceFromParameterlessLambda.ts]
|
||||
function foo<T>(o: Take<T>, i: Make<T>) { }
|
||||
interface Make<T> {
|
||||
(): T;
|
||||
}
|
||||
interface Take<T> {
|
||||
(n: T): void;
|
||||
}
|
||||
// Infer string from second argument because it isn't context sensitive
|
||||
foo(n => n.length, () => 'hi');
|
||||
|
||||
|
||||
//// [inferenceFromParameterlessLambda.js]
|
||||
function foo(o, i) {
|
||||
}
|
||||
// Infer string from second argument because it isn't context sensitive
|
||||
foo(function (n) { return n.length; }, function () { return 'hi'; });
|
|
@ -0,0 +1,37 @@
|
|||
=== tests/cases/compiler/inferenceFromParameterlessLambda.ts ===
|
||||
function foo<T>(o: Take<T>, i: Make<T>) { }
|
||||
>foo : <T>(o: Take<T>, i: Make<T>) => void
|
||||
>T : T
|
||||
>o : Take<T>
|
||||
>Take : Take<T>
|
||||
>T : T
|
||||
>i : Make<T>
|
||||
>Make : Make<T>
|
||||
>T : T
|
||||
|
||||
interface Make<T> {
|
||||
>Make : Make<T>
|
||||
>T : T
|
||||
|
||||
(): T;
|
||||
>T : T
|
||||
}
|
||||
interface Take<T> {
|
||||
>Take : Take<T>
|
||||
>T : T
|
||||
|
||||
(n: T): void;
|
||||
>n : T
|
||||
>T : T
|
||||
}
|
||||
// Infer string from second argument because it isn't context sensitive
|
||||
foo(n => n.length, () => 'hi');
|
||||
>foo(n => n.length, () => 'hi') : void
|
||||
>foo : <T>(o: Take<T>, i: Make<T>) => void
|
||||
>n => n.length : (n: string) => number
|
||||
>n : string
|
||||
>n.length : number
|
||||
>n : string
|
||||
>length : number
|
||||
>() => 'hi' : () => string
|
||||
|
9
tests/cases/compiler/inferenceFromParameterlessLambda.ts
Normal file
9
tests/cases/compiler/inferenceFromParameterlessLambda.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
function foo<T>(o: Take<T>, i: Make<T>) { }
|
||||
interface Make<T> {
|
||||
(): T;
|
||||
}
|
||||
interface Take<T> {
|
||||
(n: T): void;
|
||||
}
|
||||
// Infer string from second argument because it isn't context sensitive
|
||||
foo(n => n.length, () => 'hi');
|
|
@ -34,7 +34,7 @@ declare var FourSlash;
|
|||
// Return code used by getEmitOutput function to indicate status of the function
|
||||
// It is a duplicate of the one in types.ts to expose it to testcases in fourslash
|
||||
enum EmitReturnStatus {
|
||||
Succeeded = 0, // All outputs generated as requested (.js, .map, .d.ts), no errors reported
|
||||
Succeeded = 0, // All outputs generated if requested (.js, .map, .d.ts), no errors reported
|
||||
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, or compiler options errors, nothing generated
|
||||
JSGeneratedWithSemanticErrors = 2, // .js and .map generated with semantic errors
|
||||
DeclarationGenerationSkipped = 3, // .d.ts generation skipped because of semantic errors or declaration emitter specific errors; Output .js with semantic errors
|
||||
|
|
Loading…
Reference in a new issue