Skip to content

Commit 88d580f

Browse files
committed
Merge branch 'master' into emit-module-in-strict-mode
2 parents 4e52ab4 + fb76dc9 commit 88d580f

10 files changed

Lines changed: 153 additions & 10 deletions

src/compiler/checker.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,16 +1028,12 @@ namespace ts {
10281028

10291029
// Module names are escaped in our symbol table. However, string literal values aren't.
10301030
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
1031-
let moduleName = escapeIdentifier(moduleReferenceLiteral.text);
1031+
const moduleName = escapeIdentifier(moduleReferenceLiteral.text);
10321032

10331033
if (moduleName === undefined) {
10341034
return;
10351035
}
10361036

1037-
if (moduleName.indexOf("!") >= 0) {
1038-
moduleName = moduleName.substr(0, moduleName.indexOf("!"));
1039-
}
1040-
10411037
const isRelative = isExternalModuleNameRelative(moduleName);
10421038
if (!isRelative) {
10431039
const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);
@@ -5228,9 +5224,12 @@ namespace ts {
52285224
const id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id;
52295225
const related = relation[id];
52305226
if (related !== undefined) {
5231-
// If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate
5232-
// errors, we can use the cached value. Otherwise, recompute the relation
5233-
if (!elaborateErrors || (related === RelationComparisonResult.FailedAndReported)) {
5227+
if (elaborateErrors && related === RelationComparisonResult.Failed) {
5228+
// We are elaborating errors and the cached result is an unreported failure. Record the result as a reported
5229+
// failure and continue computing the relation such that errors get reported.
5230+
relation[id] = RelationComparisonResult.FailedAndReported;
5231+
}
5232+
else {
52345233
return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
52355234
}
52365235
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [tests/cases/compiler/bangInModuleName.ts] ////
2+
3+
//// [a.d.ts]
4+
5+
6+
declare module "http" {
7+
}
8+
9+
declare module 'intern/dojo/node!http' {
10+
import http = require('http');
11+
export = http;
12+
}
13+
14+
//// [a.ts]
15+
16+
/// <reference path="a.d.ts"/>
17+
18+
import * as http from 'intern/dojo/node!http';
19+
20+
//// [a.js]
21+
/// <reference path="a.d.ts"/>
22+
define(["require", "exports"], function (require, exports) {
23+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/a.ts ===
2+
3+
/// <reference path="a.d.ts"/>
4+
5+
import * as http from 'intern/dojo/node!http';
6+
>http : Symbol(http, Decl(a.ts, 3, 6))
7+
8+
=== tests/cases/compiler/a.d.ts ===
9+
10+
11+
declare module "http" {
12+
}
13+
14+
declare module 'intern/dojo/node!http' {
15+
import http = require('http');
16+
>http : Symbol(http, Decl(a.d.ts, 5, 40))
17+
18+
export = http;
19+
>http : Symbol(http, Decl(a.d.ts, 5, 40))
20+
}
21+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/a.ts ===
2+
3+
/// <reference path="a.d.ts"/>
4+
5+
import * as http from 'intern/dojo/node!http';
6+
>http : typeof http
7+
8+
=== tests/cases/compiler/a.d.ts ===
9+
10+
11+
declare module "http" {
12+
}
13+
14+
declare module 'intern/dojo/node!http' {
15+
import http = require('http');
16+
>http : typeof http
17+
18+
export = http;
19+
>http : typeof http
20+
}
21+

tests/baselines/reference/destructuringParameterDeclaration2.errors.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
88
Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
99
Type 'string' is not assignable to type 'number | string[][]'.
1010
Type 'string' is not assignable to type 'string[][]'.
11+
Property 'push' is missing in type 'String'.
1112
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
1213
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
1314
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(
7778
!!! error TS2345: Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
7879
!!! error TS2345: Type 'string' is not assignable to type 'number | string[][]'.
7980
!!! error TS2345: Type 'string' is not assignable to type 'string[][]'.
81+
!!! error TS2345: Property 'push' is missing in type 'String'.
8082

8183

8284
// If the declaration includes an initializer expression (which is permitted only
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
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>>'.
2+
Type 'Container<Ref<string>>' is not assignable to type 'Container<Ref<number>>'.
3+
Type 'Ref<string>' is not assignable to type 'Ref<number>'.
4+
Type 'string' is not assignable to type 'number'.
5+
6+
7+
==== tests/cases/compiler/errorElaboration.ts (1 errors) ====
8+
// Repro for #5712
9+
10+
interface Ref<T> {
11+
prop: T;
12+
}
13+
interface Container<T> {
14+
m1: Container<Ref<T>>;
15+
m2: T;
16+
}
17+
declare function foo(x: () => Container<Ref<number>>): void;
18+
let a: () => Container<Ref<string>>;
19+
foo(a);
20+
~
21+
!!! error TS2345: Argument of type '() => Container<Ref<string>>' is not assignable to parameter of type '() => Container<Ref<number>>'.
22+
!!! error TS2345: Type 'Container<Ref<string>>' is not assignable to type 'Container<Ref<number>>'.
23+
!!! error TS2345: Type 'Ref<string>' is not assignable to type 'Ref<number>'.
24+
!!! error TS2345: Type 'string' is not assignable to type 'number'.
25+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [errorElaboration.ts]
2+
// Repro for #5712
3+
4+
interface Ref<T> {
5+
prop: T;
6+
}
7+
interface Container<T> {
8+
m1: Container<Ref<T>>;
9+
m2: T;
10+
}
11+
declare function foo(x: () => Container<Ref<number>>): void;
12+
let a: () => Container<Ref<string>>;
13+
foo(a);
14+
15+
16+
//// [errorElaboration.js]
17+
// Repro for #5712
18+
var a;
19+
foo(a);

tests/baselines/reference/promisePermutations3.errors.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of
8181
Type 'number' is not assignable to type 'string'.
8282
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>'.
8383
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
84-
Property 'done' is optional in type 'IPromise<any>' but required in type 'Promise<any>'.
84+
Types of property 'then' are incompatible.
85+
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>; }'.
86+
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
8587

8688

8789
==== tests/cases/compiler/promisePermutations3.ts (35 errors) ====
@@ -368,5 +370,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
368370
~~~~~~~~~~~~~~~
369371
!!! 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>'.
370372
!!! error TS2345: Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
371-
!!! error TS2345: Property 'done' is optional in type 'IPromise<any>' but required in type 'Promise<any>'.
373+
!!! error TS2345: Types of property 'then' are incompatible.
374+
!!! 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>; }'.
375+
!!! error TS2345: Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
372376
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// @module: amd
2+
3+
// @filename: a.d.ts
4+
5+
declare module "http" {
6+
}
7+
8+
declare module 'intern/dojo/node!http' {
9+
import http = require('http');
10+
export = http;
11+
}
12+
13+
// @filename: a.ts
14+
15+
/// <reference path="a.d.ts"/>
16+
17+
import * as http from 'intern/dojo/node!http';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Repro for #5712
2+
3+
interface Ref<T> {
4+
prop: T;
5+
}
6+
interface Container<T> {
7+
m1: Container<Ref<T>>;
8+
m2: T;
9+
}
10+
declare function foo(x: () => Container<Ref<number>>): void;
11+
let a: () => Container<Ref<string>>;
12+
foo(a);

0 commit comments

Comments
 (0)