mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Rest of plain JS binder errors
This commit is contained in:
@@ -832,6 +832,9 @@ namespace ts {
|
||||
Diagnostics.Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode.code,
|
||||
Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode.code,
|
||||
Diagnostics.Invalid_use_of_0_in_strict_mode.code,
|
||||
Diagnostics.A_label_is_not_allowed_here.code,
|
||||
Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
|
||||
Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -2020,13 +2023,12 @@ namespace ts {
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
|
||||
const isCheckJs = !!isCheckJsEnabledForFile(sourceFile, options) && (sourceFile.scriptKind === ScriptKind.JS || sourceFile.scriptKind === ScriptKind.JSX);
|
||||
const isCheckJs = isCheckJsEnabledForFile(sourceFile, options) && (sourceFile.scriptKind === ScriptKind.JS || sourceFile.scriptKind === ScriptKind.JSX);
|
||||
const isPlainJs = !sourceFile.checkJsDirective && options.checkJs === undefined && (sourceFile.scriptKind === ScriptKind.JS || sourceFile.scriptKind === ScriptKind.JSX);
|
||||
const isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
|
||||
|
||||
// By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
|
||||
const includeBindAndCheckDiagnostics = !isTsNoCheck && (
|
||||
sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX
|
||||
const includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX
|
||||
|| sourceFile.scriptKind === ScriptKind.External || isPlainJs || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
|
||||
let bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
|
||||
let checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
|
||||
|
||||
+39
-17
@@ -1,28 +1,31 @@
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(1,1): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(2,1): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(3,7): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(4,7): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(6,11): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(9,11): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(12,5): error TS18012: '#constructor' is a reserved word.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(15,20): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(18,16): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(19,16): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(22,15): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'eval'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(23,15): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(26,7): error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSReservedWord.js(27,7): error TS1215: Invalid use of 'arguments'. Modules are automatically in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(1,1): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(2,1): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(3,7): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(4,7): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(6,11): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(9,11): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(12,5): error TS18012: '#constructor' is a reserved word.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(15,20): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(18,16): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(19,16): error TS1102: 'delete' cannot be called on an identifier in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(22,15): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'eval'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(23,15): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(26,27): error TS1121: Octal literals are not allowed in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(27,9): error TS1101: 'with' statements are not allowed in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(33,13): error TS1344: 'A label is not allowed here.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(39,7): error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(40,7): error TS1215: Invalid use of 'arguments'. Modules are automatically in strict mode.
|
||||
|
||||
|
||||
==== tests/cases/conformance/salsa/plainJSReservedWord.js (14 errors) ====
|
||||
==== tests/cases/conformance/salsa/plainJSBinderErrors.js (17 errors) ====
|
||||
export default 12
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2528: A module cannot have multiple default exports.
|
||||
!!! related TS2753 tests/cases/conformance/salsa/plainJSReservedWord.js:2:1: Another export default is here.
|
||||
!!! related TS2753 tests/cases/conformance/salsa/plainJSBinderErrors.js:2:1: Another export default is here.
|
||||
export default 13
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2528: A module cannot have multiple default exports.
|
||||
!!! related TS2752 tests/cases/conformance/salsa/plainJSReservedWord.js:1:1: The first export default is here.
|
||||
!!! related TS2752 tests/cases/conformance/salsa/plainJSBinderErrors.js:1:1: The first export default is here.
|
||||
const await = 1
|
||||
~~~~~
|
||||
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
|
||||
@@ -65,6 +68,25 @@ tests/cases/conformance/salsa/plainJSReservedWord.js(27,7): error TS1215: Invali
|
||||
~~~~~~~~~
|
||||
!!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
|
||||
}
|
||||
withOctal() {
|
||||
const redundant = 010
|
||||
~~~
|
||||
!!! error TS1121: Octal literals are not allowed in strict mode.
|
||||
with (redundant) {
|
||||
~~~~
|
||||
!!! error TS1101: 'with' statements are not allowed in strict mode.
|
||||
return toFixed()
|
||||
}
|
||||
}
|
||||
label() {
|
||||
for(;;) {
|
||||
label: var x = 1
|
||||
~~~~~
|
||||
!!! error TS1344: 'A label is not allowed here.
|
||||
break label
|
||||
}
|
||||
return x
|
||||
}
|
||||
}
|
||||
const eval = 9
|
||||
~~~~
|
||||
+28
-2
@@ -1,4 +1,4 @@
|
||||
//// [plainJSReservedWord.js]
|
||||
//// [plainJSBinderErrors.js]
|
||||
export default 12
|
||||
export default 13
|
||||
const await = 1
|
||||
@@ -23,12 +23,25 @@ class C {
|
||||
const eval = 7
|
||||
const arguments = 8
|
||||
}
|
||||
withOctal() {
|
||||
const redundant = 010
|
||||
with (redundant) {
|
||||
return toFixed()
|
||||
}
|
||||
}
|
||||
label() {
|
||||
for(;;) {
|
||||
label: var x = 1
|
||||
break label
|
||||
}
|
||||
return x
|
||||
}
|
||||
}
|
||||
const eval = 9
|
||||
const arguments = 10
|
||||
|
||||
|
||||
//// [plainJSReservedWord.js]
|
||||
//// [plainJSBinderErrors.js]
|
||||
export default 12;
|
||||
export default 13;
|
||||
const await = 1;
|
||||
@@ -53,6 +66,19 @@ class C {
|
||||
const eval = 7;
|
||||
const arguments = 8;
|
||||
}
|
||||
withOctal() {
|
||||
const redundant = 010;
|
||||
with (redundant) {
|
||||
return toFixed();
|
||||
}
|
||||
}
|
||||
label() {
|
||||
for (;;) {
|
||||
label: var x = 1;
|
||||
break label;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
}
|
||||
const eval = 9;
|
||||
const arguments = 10;
|
||||
@@ -0,0 +1,86 @@
|
||||
=== tests/cases/conformance/salsa/plainJSBinderErrors.js ===
|
||||
export default 12
|
||||
export default 13
|
||||
const await = 1
|
||||
>await : Symbol(await, Decl(plainJSBinderErrors.js, 2, 5))
|
||||
|
||||
const yield = 2
|
||||
>yield : Symbol(yield, Decl(plainJSBinderErrors.js, 3, 5))
|
||||
|
||||
async function f() {
|
||||
>f : Symbol(f, Decl(plainJSBinderErrors.js, 3, 15))
|
||||
|
||||
const await = 3
|
||||
>await : Symbol(await, Decl(plainJSBinderErrors.js, 5, 9))
|
||||
}
|
||||
function* g() {
|
||||
>g : Symbol(g, Decl(plainJSBinderErrors.js, 6, 1))
|
||||
|
||||
const yield = 4
|
||||
>yield : Symbol(yield, Decl(plainJSBinderErrors.js, 8, 9))
|
||||
}
|
||||
class C {
|
||||
>C : Symbol(C, Decl(plainJSBinderErrors.js, 9, 1))
|
||||
|
||||
#constructor = 5
|
||||
>#constructor : Symbol(C.#constructor, Decl(plainJSBinderErrors.js, 10, 9))
|
||||
|
||||
deleted() {
|
||||
>deleted : Symbol(C.deleted, Decl(plainJSBinderErrors.js, 11, 20))
|
||||
|
||||
function container(f) {
|
||||
>container : Symbol(container, Decl(plainJSBinderErrors.js, 12, 15))
|
||||
>f : Symbol(f, Decl(plainJSBinderErrors.js, 13, 27))
|
||||
|
||||
delete f
|
||||
>f : Symbol(f, Decl(plainJSBinderErrors.js, 13, 27))
|
||||
}
|
||||
var g = 6
|
||||
>g : Symbol(g, Decl(plainJSBinderErrors.js, 16, 11))
|
||||
|
||||
delete g
|
||||
>g : Symbol(g, Decl(plainJSBinderErrors.js, 16, 11))
|
||||
|
||||
delete container
|
||||
>container : Symbol(container, Decl(plainJSBinderErrors.js, 12, 15))
|
||||
}
|
||||
evalArguments() {
|
||||
>evalArguments : Symbol(C.evalArguments, Decl(plainJSBinderErrors.js, 19, 5))
|
||||
|
||||
const eval = 7
|
||||
>eval : Symbol(eval, Decl(plainJSBinderErrors.js, 21, 13))
|
||||
|
||||
const arguments = 8
|
||||
>arguments : Symbol(arguments, Decl(plainJSBinderErrors.js, 22, 13))
|
||||
}
|
||||
withOctal() {
|
||||
>withOctal : Symbol(C.withOctal, Decl(plainJSBinderErrors.js, 23, 5))
|
||||
|
||||
const redundant = 010
|
||||
>redundant : Symbol(redundant, Decl(plainJSBinderErrors.js, 25, 13))
|
||||
|
||||
with (redundant) {
|
||||
>redundant : Symbol(redundant, Decl(plainJSBinderErrors.js, 25, 13))
|
||||
|
||||
return toFixed()
|
||||
}
|
||||
}
|
||||
label() {
|
||||
>label : Symbol(C.label, Decl(plainJSBinderErrors.js, 29, 5))
|
||||
|
||||
for(;;) {
|
||||
label: var x = 1
|
||||
>x : Symbol(x, Decl(plainJSBinderErrors.js, 32, 22))
|
||||
|
||||
break label
|
||||
}
|
||||
return x
|
||||
>x : Symbol(x, Decl(plainJSBinderErrors.js, 32, 22))
|
||||
}
|
||||
}
|
||||
const eval = 9
|
||||
>eval : Symbol(eval, Decl(plainJSBinderErrors.js, 38, 5))
|
||||
|
||||
const arguments = 10
|
||||
>arguments : Symbol(arguments, Decl(plainJSBinderErrors.js, 39, 5))
|
||||
|
||||
+31
-1
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/conformance/salsa/plainJSReservedWord.js ===
|
||||
=== tests/cases/conformance/salsa/plainJSBinderErrors.js ===
|
||||
export default 12
|
||||
export default 13
|
||||
const await = 1
|
||||
@@ -64,6 +64,36 @@ class C {
|
||||
>arguments : 8
|
||||
>8 : 8
|
||||
}
|
||||
withOctal() {
|
||||
>withOctal : () => any
|
||||
|
||||
const redundant = 010
|
||||
>redundant : 10
|
||||
>010 : 10
|
||||
|
||||
with (redundant) {
|
||||
>redundant : 10
|
||||
|
||||
return toFixed()
|
||||
>toFixed() : any
|
||||
>toFixed : any
|
||||
}
|
||||
}
|
||||
label() {
|
||||
>label : () => number
|
||||
|
||||
for(;;) {
|
||||
label: var x = 1
|
||||
>label : any
|
||||
>x : number
|
||||
>1 : 1
|
||||
|
||||
break label
|
||||
>label : any
|
||||
}
|
||||
return x
|
||||
>x : number
|
||||
}
|
||||
}
|
||||
const eval = 9
|
||||
>eval : 9
|
||||
@@ -1,62 +0,0 @@
|
||||
=== tests/cases/conformance/salsa/plainJSReservedWord.js ===
|
||||
export default 12
|
||||
export default 13
|
||||
const await = 1
|
||||
>await : Symbol(await, Decl(plainJSReservedWord.js, 2, 5))
|
||||
|
||||
const yield = 2
|
||||
>yield : Symbol(yield, Decl(plainJSReservedWord.js, 3, 5))
|
||||
|
||||
async function f() {
|
||||
>f : Symbol(f, Decl(plainJSReservedWord.js, 3, 15))
|
||||
|
||||
const await = 3
|
||||
>await : Symbol(await, Decl(plainJSReservedWord.js, 5, 9))
|
||||
}
|
||||
function* g() {
|
||||
>g : Symbol(g, Decl(plainJSReservedWord.js, 6, 1))
|
||||
|
||||
const yield = 4
|
||||
>yield : Symbol(yield, Decl(plainJSReservedWord.js, 8, 9))
|
||||
}
|
||||
class C {
|
||||
>C : Symbol(C, Decl(plainJSReservedWord.js, 9, 1))
|
||||
|
||||
#constructor = 5
|
||||
>#constructor : Symbol(C.#constructor, Decl(plainJSReservedWord.js, 10, 9))
|
||||
|
||||
deleted() {
|
||||
>deleted : Symbol(C.deleted, Decl(plainJSReservedWord.js, 11, 20))
|
||||
|
||||
function container(f) {
|
||||
>container : Symbol(container, Decl(plainJSReservedWord.js, 12, 15))
|
||||
>f : Symbol(f, Decl(plainJSReservedWord.js, 13, 27))
|
||||
|
||||
delete f
|
||||
>f : Symbol(f, Decl(plainJSReservedWord.js, 13, 27))
|
||||
}
|
||||
var g = 6
|
||||
>g : Symbol(g, Decl(plainJSReservedWord.js, 16, 11))
|
||||
|
||||
delete g
|
||||
>g : Symbol(g, Decl(plainJSReservedWord.js, 16, 11))
|
||||
|
||||
delete container
|
||||
>container : Symbol(container, Decl(plainJSReservedWord.js, 12, 15))
|
||||
}
|
||||
evalArguments() {
|
||||
>evalArguments : Symbol(C.evalArguments, Decl(plainJSReservedWord.js, 19, 5))
|
||||
|
||||
const eval = 7
|
||||
>eval : Symbol(eval, Decl(plainJSReservedWord.js, 21, 13))
|
||||
|
||||
const arguments = 8
|
||||
>arguments : Symbol(arguments, Decl(plainJSReservedWord.js, 22, 13))
|
||||
}
|
||||
}
|
||||
const eval = 9
|
||||
>eval : Symbol(eval, Decl(plainJSReservedWord.js, 25, 5))
|
||||
|
||||
const arguments = 10
|
||||
>arguments : Symbol(arguments, Decl(plainJSReservedWord.js, 26, 5))
|
||||
|
||||
+14
-1
@@ -1,7 +1,7 @@
|
||||
// @outdir: out/
|
||||
// @target: esnext
|
||||
// @allowJS: true
|
||||
// @filename: plainJSReservedWord.js
|
||||
// @filename: plainJSBinderErrors.js
|
||||
export default 12
|
||||
export default 13
|
||||
const await = 1
|
||||
@@ -26,6 +26,19 @@ class C {
|
||||
const eval = 7
|
||||
const arguments = 8
|
||||
}
|
||||
withOctal() {
|
||||
const redundant = 010
|
||||
with (redundant) {
|
||||
return toFixed()
|
||||
}
|
||||
}
|
||||
label() {
|
||||
for(;;) {
|
||||
label: var x = 1
|
||||
break label
|
||||
}
|
||||
return x
|
||||
}
|
||||
}
|
||||
const eval = 9
|
||||
const arguments = 10
|
||||
Reference in New Issue
Block a user