Merge branch 'master' into emit-module-in-strict-mode

This commit is contained in:
Wesley Wigham 2015-11-23 17:06:02 -08:00
commit 88d580ffe7
10 changed files with 153 additions and 10 deletions

View File

@ -1028,16 +1028,12 @@ namespace ts {
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
let moduleName = escapeIdentifier(moduleReferenceLiteral.text);
const moduleName = escapeIdentifier(moduleReferenceLiteral.text);
if (moduleName === undefined) {
return;
}
if (moduleName.indexOf("!") >= 0) {
moduleName = moduleName.substr(0, moduleName.indexOf("!"));
}
const isRelative = isExternalModuleNameRelative(moduleName);
if (!isRelative) {
const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);
@ -5228,9 +5224,12 @@ namespace ts {
const id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id;
const related = relation[id];
if (related !== undefined) {
// If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate
// errors, we can use the cached value. Otherwise, recompute the relation
if (!elaborateErrors || (related === RelationComparisonResult.FailedAndReported)) {
if (elaborateErrors && related === RelationComparisonResult.Failed) {
// We are elaborating errors and the cached result is an unreported failure. Record the result as a reported
// failure and continue computing the relation such that errors get reported.
relation[id] = RelationComparisonResult.FailedAndReported;
}
else {
return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
}
}

View File

@ -0,0 +1,23 @@
//// [tests/cases/compiler/bangInModuleName.ts] ////
//// [a.d.ts]
declare module "http" {
}
declare module 'intern/dojo/node!http' {
import http = require('http');
export = http;
}
//// [a.ts]
/// <reference path="a.d.ts"/>
import * as http from 'intern/dojo/node!http';
//// [a.js]
/// <reference path="a.d.ts"/>
define(["require", "exports"], function (require, exports) {
});

View File

@ -0,0 +1,21 @@
=== tests/cases/compiler/a.ts ===
/// <reference path="a.d.ts"/>
import * as http from 'intern/dojo/node!http';
>http : Symbol(http, Decl(a.ts, 3, 6))
=== tests/cases/compiler/a.d.ts ===
declare module "http" {
}
declare module 'intern/dojo/node!http' {
import http = require('http');
>http : Symbol(http, Decl(a.d.ts, 5, 40))
export = http;
>http : Symbol(http, Decl(a.d.ts, 5, 40))
}

View File

@ -0,0 +1,21 @@
=== tests/cases/compiler/a.ts ===
/// <reference path="a.d.ts"/>
import * as http from 'intern/dojo/node!http';
>http : typeof http
=== tests/cases/compiler/a.d.ts ===
declare module "http" {
}
declare module 'intern/dojo/node!http' {
import http = require('http');
>http : typeof http
export = http;
>http : typeof http
}

View File

@ -8,6 +8,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
Type 'string' is not assignable to type 'number | string[][]'.
Type 'string' is not assignable to type 'string[][]'.
Property 'push' is missing in type 'String'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,14): error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'.
@ -77,6 +78,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
!!! error TS2345: Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
!!! error TS2345: Type 'string' is not assignable to type 'number | string[][]'.
!!! error TS2345: Type 'string' is not assignable to type 'string[][]'.
!!! error TS2345: Property 'push' is missing in type 'String'.
// If the declaration includes an initializer expression (which is permitted only

View File

@ -0,0 +1,25 @@
tests/cases/compiler/errorElaboration.ts(12,5): error TS2345: Argument of type '() => Container<Ref<string>>' is not assignable to parameter of type '() => Container<Ref<number>>'.
Type 'Container<Ref<string>>' is not assignable to type 'Container<Ref<number>>'.
Type 'Ref<string>' is not assignable to type 'Ref<number>'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/compiler/errorElaboration.ts (1 errors) ====
// Repro for #5712
interface Ref<T> {
prop: T;
}
interface Container<T> {
m1: Container<Ref<T>>;
m2: T;
}
declare function foo(x: () => Container<Ref<number>>): void;
let a: () => Container<Ref<string>>;
foo(a);
~
!!! error TS2345: Argument of type '() => Container<Ref<string>>' is not assignable to parameter of type '() => Container<Ref<number>>'.
!!! error TS2345: Type 'Container<Ref<string>>' is not assignable to type 'Container<Ref<number>>'.
!!! error TS2345: Type 'Ref<string>' is not assignable to type 'Ref<number>'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.

View File

@ -0,0 +1,19 @@
//// [errorElaboration.ts]
// Repro for #5712
interface Ref<T> {
prop: T;
}
interface Container<T> {
m1: Container<Ref<T>>;
m2: T;
}
declare function foo(x: () => Container<Ref<number>>): void;
let a: () => Container<Ref<string>>;
foo(a);
//// [errorElaboration.js]
// Repro for #5712
var a;
foo(a);

View File

@ -81,7 +81,9 @@ tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<any>'.
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
Property 'done' is optional in type 'IPromise<any>' but required in type 'Promise<any>'.
Types of property 'then' are incompatible.
Type '<U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <U>(success?: (value: any) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
==== tests/cases/compiler/promisePermutations3.ts (35 errors) ====
@ -368,5 +370,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<any>'.
!!! error TS2345: Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
!!! error TS2345: Property 'done' is optional in type 'IPromise<any>' but required in type 'Promise<any>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '<U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <U>(success?: (value: any) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok

View File

@ -0,0 +1,17 @@
// @module: amd
// @filename: a.d.ts
declare module "http" {
}
declare module 'intern/dojo/node!http' {
import http = require('http');
export = http;
}
// @filename: a.ts
/// <reference path="a.d.ts"/>
import * as http from 'intern/dojo/node!http';

View File

@ -0,0 +1,12 @@
// Repro for #5712
interface Ref<T> {
prop: T;
}
interface Container<T> {
m1: Container<Ref<T>>;
m2: T;
}
declare function foo(x: () => Container<Ref<number>>): void;
let a: () => Container<Ref<string>>;
foo(a);