Merge pull request #17994 from Microsoft/allow-question-token-as-start-of-type

Allow question token as start of type
This commit is contained in:
Nathan Shively-Sanders 2017-08-23 15:40:25 -07:00 committed by GitHub
commit 356f54af3d
8 changed files with 19 additions and 50 deletions

View file

@ -2721,6 +2721,7 @@ namespace ts {
case SyntaxKind.FalseKeyword:
case SyntaxKind.ObjectKeyword:
case SyntaxKind.AsteriskToken:
case SyntaxKind.QuestionToken:
return true;
case SyntaxKind.MinusToken:
return lookAhead(nextTokenIsNumericLiteral);

View file

@ -1,21 +0,0 @@
tests/cases/conformance/jsdoc/0.js(5,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
tests/cases/conformance/jsdoc/0.js(12,1): error TS2322: Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/jsdoc/0.js (2 errors) ====
// @ts-check
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1("string");
~~~~~~~~
!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
/** @type {function (number): number} */
const x2 = (a) => a + 1;
/** @type {string} */
var a;
a = x2(0);
~
!!! error TS2322: Type 'number' is not assignable to type 'string'.

View file

@ -1,24 +0,0 @@
//// [0.js]
// @ts-check
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1("string");
/** @type {function (number): number} */
const x2 = (a) => a + 1;
/** @type {string} */
var a;
a = x2(0);
//// [0.js]
// @ts-check
/** @type {function (number)} */
var x1 = function (a) { return a + 1; };
x1("string");
/** @type {function (number): number} */
var x2 = function (a) { return a + 1; };
/** @type {string} */
var a;
a = x2(0);

View file

@ -0,0 +1,5 @@
=== tests/cases/conformance/jsdoc/test.js ===
/** @type {Array<?number>} */
var nns;
>nns : Symbol(nns, Decl(test.js, 1, 3))

View file

@ -0,0 +1,5 @@
=== tests/cases/conformance/jsdoc/test.js ===
/** @type {Array<?number>} */
var nns;
>nns : number[]

View file

@ -84,7 +84,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,20): e
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,23): error TS1003: Identifier expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,27): error TS1005: ',' expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,23): error TS1005: ',' expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,24): error TS1138: Parameter declaration expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,28): error TS1003: Identifier expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,32): error TS1005: ',' expected.
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,30): error TS1005: ',' expected.
@ -94,7 +93,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,32): e
tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): error TS2304: Cannot find name 'm'.
==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (60 errors) ====
==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (59 errors) ====
class C {
n: number;
explicitThis(this: this, m: number): number {
@ -403,8 +402,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e
function optional(this?: C): number { return this.n; }
~
!!! error TS1005: ',' expected.
~
!!! error TS1138: Parameter declaration expected.
function decorated(@deco() this: C): number { return this.n; }
~~~~
!!! error TS1003: Identifier expected.

View file

@ -345,7 +345,7 @@ function modifiers(, C) {
return this.n;
}
function restParam(C) { return this.n; }
function optional(C) { return this.n; }
function optional() { return this.n; }
function decorated(, C) {
if ( === void 0) { = this; }
return this.n;

View file

@ -0,0 +1,6 @@
// @Filename:test.js
// @checkJs: true
// @allowJs: true
// @noEmit: true
/** @type {Array<?number>} */
var nns;