Merge pull request #1160 from Microsoft/weDontNeedNoTemplateStringsArrayPreEs6
Default to 'unknown' for the template strings array type in pre-ES6 targets.
This commit is contained in:
commit
aec8d9621c
|
@ -9102,7 +9102,12 @@ module ts {
|
||||||
globalNumberType = getGlobalType("Number");
|
globalNumberType = getGlobalType("Number");
|
||||||
globalBooleanType = getGlobalType("Boolean");
|
globalBooleanType = getGlobalType("Boolean");
|
||||||
globalRegExpType = getGlobalType("RegExp");
|
globalRegExpType = getGlobalType("RegExp");
|
||||||
globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray");
|
|
||||||
|
// If we're in ES6 mode, load the TemplateStringsArray.
|
||||||
|
// Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios.
|
||||||
|
globalTemplateStringsArrayType = compilerOptions.target >= ScriptTarget.ES6
|
||||||
|
? getGlobalType("TemplateStringsArray")
|
||||||
|
: unknownType;
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeTypeChecker();
|
initializeTypeChecker();
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
/// <reference path='..\services\services.ts' />
|
/// <reference path='..\services\services.ts' />
|
||||||
/// <reference path='..\services\shims.ts' />
|
/// <reference path='..\services\shims.ts' />
|
||||||
|
/// <reference path='..\compiler\core.ts' />
|
||||||
/// <reference path='..\compiler\sys.ts' />
|
/// <reference path='..\compiler\sys.ts' />
|
||||||
/// <reference path='external\mocha.d.ts'/>
|
/// <reference path='external\mocha.d.ts'/>
|
||||||
/// <reference path='external\chai.d.ts'/>
|
/// <reference path='external\chai.d.ts'/>
|
||||||
|
@ -1002,8 +1003,12 @@ module Harness {
|
||||||
assert.equal(markedErrorCount, fileErrors.length, 'count of errors in ' + inputFile.unitName);
|
assert.equal(markedErrorCount, fileErrors.length, 'count of errors in ' + inputFile.unitName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||||
|
return diagnostic.filename && isLibraryFile(diagnostic.filename);
|
||||||
|
});
|
||||||
|
|
||||||
// Verify we didn't miss any errors in total
|
// Verify we didn't miss any errors in total
|
||||||
assert.equal(totalErrorsReported, diagnostics.length, 'total number of errors');
|
assert.equal(totalErrorsReported + numLibraryDiagnostics, diagnostics.length, 'total number of errors');
|
||||||
|
|
||||||
return minimalDiagnosticsToString(diagnostics) +
|
return minimalDiagnosticsToString(diagnostics) +
|
||||||
sys.newLine + sys.newLine + outputLines.join('\r\n');
|
sys.newLine + sys.newLine + outputLines.join('\r\n');
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
error TS2318: Cannot find global type 'Boolean'.
|
error TS2318: Cannot find global type 'Boolean'.
|
||||||
error TS2318: Cannot find global type 'IArguments'.
|
error TS2318: Cannot find global type 'IArguments'.
|
||||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
tests/cases/compiler/noDefaultLib.ts(4,11): error TS2317: Global type 'Array' must have 1 type parameter(s).
|
tests/cases/compiler/noDefaultLib.ts(4,11): error TS2317: Global type 'Array' must have 1 type parameter(s).
|
||||||
|
|
||||||
|
|
||||||
!!! error TS2318: Cannot find global type 'Boolean'.
|
!!! error TS2318: Cannot find global type 'Boolean'.
|
||||||
!!! error TS2318: Cannot find global type 'IArguments'.
|
!!! error TS2318: Cannot find global type 'IArguments'.
|
||||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
==== tests/cases/compiler/noDefaultLib.ts (1 errors) ====
|
==== tests/cases/compiler/noDefaultLib.ts (1 errors) ====
|
||||||
/// <reference no-default-lib="true"/>
|
/// <reference no-default-lib="true"/>
|
||||||
var x;
|
var x;
|
||||||
|
|
|
@ -6,7 +6,6 @@ error TS2318: Cannot find global type 'Number'.
|
||||||
error TS2318: Cannot find global type 'Object'.
|
error TS2318: Cannot find global type 'Object'.
|
||||||
error TS2318: Cannot find global type 'RegExp'.
|
error TS2318: Cannot find global type 'RegExp'.
|
||||||
error TS2318: Cannot find global type 'String'.
|
error TS2318: Cannot find global type 'String'.
|
||||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
|
|
||||||
|
|
||||||
!!! error TS2318: Cannot find global type 'Array'.
|
!!! error TS2318: Cannot find global type 'Array'.
|
||||||
|
@ -17,7 +16,6 @@ error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||||
!!! error TS2318: Cannot find global type 'Object'.
|
!!! error TS2318: Cannot find global type 'Object'.
|
||||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||||
!!! error TS2318: Cannot find global type 'String'.
|
!!! error TS2318: Cannot find global type 'String'.
|
||||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ====
|
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ====
|
||||||
/// <style requireSemi="on" />
|
/// <style requireSemi="on" />
|
||||||
/// <reference no-default-lib="true"/>
|
/// <reference no-default-lib="true"/>
|
||||||
|
|
|
@ -6,7 +6,6 @@ error TS2318: Cannot find global type 'Number'.
|
||||||
error TS2318: Cannot find global type 'Object'.
|
error TS2318: Cannot find global type 'Object'.
|
||||||
error TS2318: Cannot find global type 'RegExp'.
|
error TS2318: Cannot find global type 'RegExp'.
|
||||||
error TS2318: Cannot find global type 'String'.
|
error TS2318: Cannot find global type 'String'.
|
||||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +17,6 @@ test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||||
!!! error TS2318: Cannot find global type 'Object'.
|
!!! error TS2318: Cannot find global type 'Object'.
|
||||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||||
!!! error TS2318: Cannot find global type 'String'.
|
!!! error TS2318: Cannot find global type 'String'.
|
||||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
==== test.ts (1 errors) ====
|
==== test.ts (1 errors) ====
|
||||||
/// <reference no-default-lib="true"/>
|
/// <reference no-default-lib="true"/>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ error TS2318: Cannot find global type 'Number'.
|
||||||
error TS2318: Cannot find global type 'Object'.
|
error TS2318: Cannot find global type 'Object'.
|
||||||
error TS2318: Cannot find global type 'RegExp'.
|
error TS2318: Cannot find global type 'RegExp'.
|
||||||
error TS2318: Cannot find global type 'String'.
|
error TS2318: Cannot find global type 'String'.
|
||||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +17,6 @@ test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||||
!!! error TS2318: Cannot find global type 'Object'.
|
!!! error TS2318: Cannot find global type 'Object'.
|
||||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||||
!!! error TS2318: Cannot find global type 'String'.
|
!!! error TS2318: Cannot find global type 'String'.
|
||||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
==== test.ts (1 errors) ====
|
==== test.ts (1 errors) ====
|
||||||
/// <reference no-default-lib="true"/>
|
/// <reference no-default-lib="true"/>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||||
|
lib.d.ts(502,11): error TS2300: Duplicate identifier 'TemplateStringsArray'.
|
||||||
|
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'.
|
||||||
|
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||||
|
Property 'raw' is missing in type '{ [x: number]: undefined; }'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (3 errors) ====
|
||||||
|
|
||||||
|
class TemplateStringsArray {
|
||||||
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2300: Duplicate identifier 'TemplateStringsArray'.
|
||||||
|
}
|
||||||
|
|
||||||
|
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||||
|
}
|
||||||
|
|
||||||
|
f({}, 10, 10);
|
||||||
|
~~
|
||||||
|
!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||||
|
!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'.
|
||||||
|
|
||||||
|
f `abcdef${ 1234 }${ 5678 }ghijkl`;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
|
@ -0,0 +1,18 @@
|
||||||
|
tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(7,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||||
|
tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(5,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||||
|
Property 'raw' is missing in type '{ [x: number]: undefined; }'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts (2 errors) ====
|
||||||
|
|
||||||
|
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||||
|
}
|
||||||
|
|
||||||
|
f({}, 10, 10);
|
||||||
|
~~
|
||||||
|
!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||||
|
!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'.
|
||||||
|
|
||||||
|
f `abcdef${ 1234 }${ 5678 }ghijkl`;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
|
@ -0,0 +1,22 @@
|
||||||
|
lib.d.ts(502,11): error TS2300: Duplicate identifier 'TemplateStringsArray'.
|
||||||
|
tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'.
|
||||||
|
tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||||
|
Property 'raw' is missing in type '{ [x: number]: undefined; }'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (2 errors) ====
|
||||||
|
|
||||||
|
class TemplateStringsArray {
|
||||||
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2300: Duplicate identifier 'TemplateStringsArray'.
|
||||||
|
}
|
||||||
|
|
||||||
|
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||||
|
}
|
||||||
|
|
||||||
|
f({}, 10, 10);
|
||||||
|
~~
|
||||||
|
!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||||
|
!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'.
|
||||||
|
|
||||||
|
f `abcdef${ 1234 }${ 5678 }ghijkl`;
|
|
@ -0,0 +1,22 @@
|
||||||
|
//// [templateStringsArrayTypeRedefinedInES6Mode.ts]
|
||||||
|
|
||||||
|
class TemplateStringsArray {
|
||||||
|
}
|
||||||
|
|
||||||
|
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||||
|
}
|
||||||
|
|
||||||
|
f({}, 10, 10);
|
||||||
|
|
||||||
|
f `abcdef${ 1234 }${ 5678 }ghijkl`;
|
||||||
|
|
||||||
|
//// [templateStringsArrayTypeRedefinedInES6Mode.js]
|
||||||
|
var TemplateStringsArray = (function () {
|
||||||
|
function TemplateStringsArray() {
|
||||||
|
}
|
||||||
|
return TemplateStringsArray;
|
||||||
|
})();
|
||||||
|
function f(x, y, z) {
|
||||||
|
}
|
||||||
|
f({}, 10, 10);
|
||||||
|
f `abcdef${1234}${5678}ghijkl`;
|
|
@ -6,7 +6,6 @@ error TS2318: Cannot find global type 'Number'.
|
||||||
error TS2318: Cannot find global type 'Object'.
|
error TS2318: Cannot find global type 'Object'.
|
||||||
error TS2318: Cannot find global type 'RegExp'.
|
error TS2318: Cannot find global type 'RegExp'.
|
||||||
error TS2318: Cannot find global type 'String'.
|
error TS2318: Cannot find global type 'String'.
|
||||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
tests/cases/compiler/typeCheckTypeArgument.ts(3,19): error TS2304: Cannot find name 'UNKNOWN'.
|
tests/cases/compiler/typeCheckTypeArgument.ts(3,19): error TS2304: Cannot find name 'UNKNOWN'.
|
||||||
tests/cases/compiler/typeCheckTypeArgument.ts(5,26): error TS2304: Cannot find name 'UNKNOWN'.
|
tests/cases/compiler/typeCheckTypeArgument.ts(5,26): error TS2304: Cannot find name 'UNKNOWN'.
|
||||||
tests/cases/compiler/typeCheckTypeArgument.ts(7,21): error TS2304: Cannot find name 'UNKNOWN'.
|
tests/cases/compiler/typeCheckTypeArgument.ts(7,21): error TS2304: Cannot find name 'UNKNOWN'.
|
||||||
|
@ -23,7 +22,6 @@ tests/cases/compiler/typeCheckTypeArgument.ts(15,13): error TS2304: Cannot find
|
||||||
!!! error TS2318: Cannot find global type 'Object'.
|
!!! error TS2318: Cannot find global type 'Object'.
|
||||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||||
!!! error TS2318: Cannot find global type 'String'.
|
!!! error TS2318: Cannot find global type 'String'.
|
||||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
|
||||||
==== tests/cases/compiler/typeCheckTypeArgument.ts (6 errors) ====
|
==== tests/cases/compiler/typeCheckTypeArgument.ts (6 errors) ====
|
||||||
/// <reference no-default-lib="true"/>
|
/// <reference no-default-lib="true"/>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
// @target: es5
|
||||||
|
|
||||||
|
class TemplateStringsArray {
|
||||||
|
}
|
||||||
|
|
||||||
|
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||||
|
}
|
||||||
|
|
||||||
|
f({}, 10, 10);
|
||||||
|
|
||||||
|
f `abcdef${ 1234 }${ 5678 }ghijkl`;
|
|
@ -0,0 +1,8 @@
|
||||||
|
// @target: es5
|
||||||
|
|
||||||
|
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||||
|
}
|
||||||
|
|
||||||
|
f({}, 10, 10);
|
||||||
|
|
||||||
|
f `abcdef${ 1234 }${ 5678 }ghijkl`;
|
|
@ -0,0 +1,11 @@
|
||||||
|
// @target: es6
|
||||||
|
|
||||||
|
class TemplateStringsArray {
|
||||||
|
}
|
||||||
|
|
||||||
|
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||||
|
}
|
||||||
|
|
||||||
|
f({}, 10, 10);
|
||||||
|
|
||||||
|
f `abcdef${ 1234 }${ 5678 }ghijkl`;
|
Loading…
Reference in a new issue