-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32965 from ajafff/ts-in-js
Detect more TS syntax in JS files
- Loading branch information
Showing
8 changed files
with
69 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. | ||
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. | ||
tests/cases/compiler/a.js(2,8): error TS8009: '?' can only be used in a .ts file. | ||
tests/cases/compiler/a.js(4,8): error TS8009: '?' can only be used in a .ts file. | ||
|
||
|
||
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. | ||
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. | ||
==== tests/cases/compiler/a.js (2 errors) ==== | ||
class C { | ||
foo?() { | ||
~ | ||
!!! error TS8009: '?' can only be used in a .ts file. | ||
} | ||
bar? = 1; | ||
~ | ||
!!! error TS8009: '?' can only be used in a .ts file. | ||
} |
20 changes: 14 additions & 6 deletions
20
tests/baselines/reference/jsFileCompilationTypeArgumentSyntaxOfCall.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. | ||
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. | ||
tests/cases/compiler/a.js(1,5): error TS8011: 'type arguments' can only be used in a .ts file. | ||
tests/cases/compiler/a.jsx(1,5): error TS8011: 'type arguments' can only be used in a .ts file. | ||
tests/cases/compiler/a.jsx(2,5): error TS8011: 'type arguments' can only be used in a .ts file. | ||
tests/cases/compiler/a.jsx(3,6): error TS8011: 'type arguments' can only be used in a .ts file. | ||
tests/cases/compiler/a.jsx(4,6): error TS8011: 'type arguments' can only be used in a .ts file. | ||
|
||
|
||
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. | ||
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. | ||
==== tests/cases/compiler/a.js (1 errors) ==== | ||
==== tests/cases/compiler/a.jsx (4 errors) ==== | ||
Foo<number>(); | ||
~~~~~~ | ||
!!! error TS8011: 'type arguments' can only be used in a .ts file. | ||
Foo<number>``; | ||
~~~~~~ | ||
!!! error TS8011: 'type arguments' can only be used in a .ts file. | ||
<Foo<number>></Foo>; | ||
~~~~~~ | ||
!!! error TS8011: 'type arguments' can only be used in a .ts file. | ||
<Foo<number>/>; | ||
~~~~~~ | ||
!!! error TS8011: 'type arguments' can only be used in a .ts file. |
15 changes: 15 additions & 0 deletions
15
tests/baselines/reference/jsFileCompilationTypeArgumentSyntaxOfCall.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//// [a.jsx] | ||
Foo<number>(); | ||
Foo<number>``; | ||
<Foo<number>></Foo>; | ||
<Foo<number>/>; | ||
|
||
//// [a.js] | ||
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { | ||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } | ||
return cooked; | ||
}; | ||
Foo(); | ||
Foo(__makeTemplateObject([""], [""])); | ||
<Foo></Foo>; | ||
<Foo />; |
3 changes: 0 additions & 3 deletions
3
tests/baselines/reference/jsFileCompilationTypeArgumentSyntaxOfCall.symbols
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
tests/baselines/reference/jsFileCompilationTypeArgumentSyntaxOfCall.types
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
tests/cases/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @allowJs: true | ||
// @noTypesAndSymbols: true | ||
// @filename: a.js | ||
class C { | ||
foo?() { | ||
} | ||
bar? = 1; | ||
} |
8 changes: 6 additions & 2 deletions
8
tests/cases/compiler/jsFileCompilationTypeArgumentSyntaxOfCall.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
// @allowJs: true | ||
// @filename: a.js | ||
Foo<number>(); | ||
// @noTypesAndSymbols: true | ||
// @filename: a.jsx | ||
Foo<number>(); | ||
Foo<number>``; | ||
<Foo<number>></Foo>; | ||
<Foo<number>/>; |