Skip to content

Allow bang+dotdotdot as start of type #18014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2722,6 +2722,8 @@ namespace ts {
case SyntaxKind.ObjectKeyword:
case SyntaxKind.AsteriskToken:
case SyntaxKind.QuestionToken:
case SyntaxKind.ExclamationToken:
case SyntaxKind.DotDotDotToken:
return true;
case SyntaxKind.MinusToken:
return lookAhead(nextTokenIsNumericLiteral);
Expand Down
20 changes: 19 additions & 1 deletion tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(17,11): error TS802
tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(18,17): error TS8020: JSDoc types can only be used inside documentation comments.
tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(19,5): error TS2322: Type 'undefined' is not assignable to type 'number | null'.
tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(19,17): error TS8020: JSDoc types can only be used inside documentation comments.
tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(21,16): error TS8020: JSDoc types can only be used inside documentation comments.
tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(22,16): error TS8020: JSDoc types can only be used inside documentation comments.
tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(23,17): error TS8020: JSDoc types can only be used inside documentation comments.
tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS8020: JSDoc types can only be used inside documentation comments.


==== tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts (14 errors) ====
==== tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts (18 errors) ====
// grammar error from checker
var ara: Array.<number> = [1,2,3];
~
Expand Down Expand Up @@ -62,4 +66,18 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(19,17): error TS802
!!! error TS2322: Type 'undefined' is not assignable to type 'number | null'.
~~~~~~~
!!! error TS8020: JSDoc types can only be used inside documentation comments.

var nns: Array<?number>;
~~~~~~~
!!! error TS8020: JSDoc types can only be used inside documentation comments.
var dns: Array<!number>;
~~~~~~~
!!! error TS8020: JSDoc types can only be used inside documentation comments.
var anys: Array<*>;
~
!!! error TS8020: JSDoc types can only be used inside documentation comments.
var vars: Array<...number>;
~~~~~~~~~
!!! error TS8020: JSDoc types can only be used inside documentation comments.


10 changes: 10 additions & 0 deletions tests/baselines/reference/jsdocDisallowedInTypescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ var variadic: ...boolean = [true, false, true];
var most: !string = 'definite';
var postfixdef: number! = 101;
var postfixopt: number? = undefined;

var nns: Array<?number>;
var dns: Array<!number>;
var anys: Array<*>;
var vars: Array<...number>;



//// [jsdocDisallowedInTypescript.js]
Expand All @@ -40,3 +46,7 @@ var variadic = [true, false, true];
var most = 'definite';
var postfixdef = 101;
var postfixopt = undefined;
var nns;
var dns;
var anys;
var vars;
6 changes: 6 additions & 0 deletions tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ var variadic: ...boolean = [true, false, true];
var most: !string = 'definite';
var postfixdef: number! = 101;
var postfixopt: number? = undefined;

var nns: Array<?number>;
var dns: Array<!number>;
var anys: Array<*>;
var vars: Array<...number>;