From cdfef4fa571a87b39d44622026108cc16868b927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Fri, 13 Jul 2018 15:07:38 +0800 Subject: [PATCH 1/3] add use strict and simple parameter check --- src/compiler/checker.ts | 40 +++++- src/compiler/diagnosticMessages.json | 12 ++ src/compiler/factory.ts | 27 +++-- ...tionWithUseStrictAndSimpleParameterList.js | 101 ++++++++++++++++ ...ithUseStrictAndSimpleParameterList.symbols | 83 +++++++++++++ ...nWithUseStrictAndSimpleParameterList.types | 109 +++++++++++++++++ ...ctAndSimpleParameterList_es2016.errors.txt | 114 ++++++++++++++++++ ...hUseStrictAndSimpleParameterList_es2016.js | 83 +++++++++++++ ...trictAndSimpleParameterList_es2016.symbols | 83 +++++++++++++ ...eStrictAndSimpleParameterList_es2016.types | 109 +++++++++++++++++ ...tionWithUseStrictAndSimpleParameterList.ts | 44 +++++++ ...hUseStrictAndSimpleParameterList_es2016.ts | 46 +++++++ 12 files changed, 838 insertions(+), 13 deletions(-) create mode 100644 tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js create mode 100644 tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols create mode 100644 tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types create mode 100644 tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt create mode 100644 tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js create mode 100644 tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols create mode 100644 tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types create mode 100644 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts create mode 100644 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cd91f427248..e97fc933839 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28515,11 +28515,49 @@ namespace ts { } } + function getNonSimpleParameters(parameters: ReadonlyArray): ReadonlyArray { + // ECMA-262 14.1.13 + if (parameters.length === 0) return []; + + const last = lastOrUndefined(parameters); + if (last && isRestParameter(last)) return [last]; + + return filter(parameters, parameter => { + // ECMA-262 13.3.3.4 + return !!parameter.initializer || isBindingPattern(parameter.name); + }); + } + + function checkGrammarForUseStrictSimpleParameterList(node: FunctionLikeDeclaration): boolean { + if (languageVersion >= ScriptTarget.ES2016) { + const useStrictDirective = node.body && isBlock(node.body) && findUseStrictPrologue(node.body.statements); + if (useStrictDirective) { + const nonSimpleParameters = getNonSimpleParameters(node.parameters); + if (length(nonSimpleParameters)) { + forEach(nonSimpleParameters, parameter => { + addRelatedInfo( + error(parameter, Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), + createDiagnosticForNode(useStrictDirective, Diagnostics._0_is_here, "use strict directive") + ); + }); + + const diagnostics = nonSimpleParameters.map((parameter, index) => ( + index === 0 ? createDiagnosticForNode(parameter, Diagnostics._0_is_here, "parameter") : createDiagnosticForNode(parameter, Diagnostics.and_here) + )) as [DiagnosticWithLocation, ...DiagnosticWithLocation[]]; + addRelatedInfo(error(useStrictDirective, Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list), ...diagnostics); + return true; + } + } + } + return false; + } + function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration | MethodSignature): boolean { // Prevent cascading error by short-circuit const file = getSourceFileOfNode(node); return checkGrammarDecoratorsAndModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || - checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file) || + (isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node)); } function checkGrammarClassLikeDeclaration(node: ClassLikeDeclaration): boolean { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 73be2b46b79..9a1690ebe55 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -983,6 +983,18 @@ "category": "Error", "code": 1343 }, + "This parameter is not allowed with 'use strict' directive.": { + "category": "Error", + "code": 1344 + }, + "'use strict' directive cannot be used with non simple parameter list.": { + "category": "Error", + "code": 1345 + }, + "{0} is here.": { + "category": "Error", + "code": 1346 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 86911417cb6..09b3386d24e 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3934,6 +3934,20 @@ namespace ts { return statementOffset; } + export function findUseStrictPrologue(statements: ReadonlyArray): Statement | undefined { + for (const statement of statements) { + if (isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + return statement; + } + } + else { + break; + } + } + return undefined; + } + export function startsWithUseStrict(statements: ReadonlyArray) { const firstStatement = firstOrUndefined(statements); return firstStatement !== undefined @@ -3947,18 +3961,7 @@ namespace ts { * @param statements An array of statements */ export function ensureUseStrict(statements: NodeArray): NodeArray { - let foundUseStrict = false; - for (const statement of statements) { - if (isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement as ExpressionStatement)) { - foundUseStrict = true; - break; - } - } - else { - break; - } - } + const foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { return setTextRange( diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js new file mode 100644 index 00000000000..260f0df874a --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js @@ -0,0 +1,101 @@ +//// [functionWithUseStrictAndSimpleParameterList.ts] +function a(a = 10) { + "use strict"; +} + +export var foo = 10; +function b(a = 10) { +} + +function container() { + "use strict"; + function f(a = 10) { + } +} + +function rest(...args: any[]) { + 'use strict'; +} + +function paramDefault(param = 1) { + 'use strict'; +} + +function objectBindingPattern({foo}: any) { + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} + + +//// [functionWithUseStrictAndSimpleParameterList.js] +"use strict"; +exports.__esModule = true; +function a(a) { + "use strict"; + if (a === void 0) { a = 10; } +} +exports.foo = 10; +function b(a) { + if (a === void 0) { a = 10; } +} +function container() { + "use strict"; + function f(a) { + if (a === void 0) { a = 10; } + } +} +function rest() { + 'use strict'; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } +} +function paramDefault(param) { + 'use strict'; + if (param === void 0) { param = 1; } +} +function objectBindingPattern(_a) { + 'use strict'; + var foo = _a.foo; +} +function arrayBindingPattern(_a) { + 'use strict'; + var foo = _a[0]; +} +function manyParameter(a, b) { + "use strict"; + if (a === void 0) { a = 10; } + if (b === void 0) { b = 20; } +} +function manyPrologue(a, b) { + "foo"; + "use strict"; + if (a === void 0) { a = 10; } + if (b === void 0) { b = 20; } +} +function invalidPrologue(a, b) { + "foo"; + if (a === void 0) { a = 10; } + if (b === void 0) { b = 20; } + var c = 1; + "use strict"; +} diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols new file mode 100644 index 00000000000..59c8190883f --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols @@ -0,0 +1,83 @@ +=== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts === +function a(a = 10) { +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 0, 0)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 0, 11)) + + "use strict"; +} + +export var foo = 10; +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 4, 10)) + +function b(a = 10) { +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 4, 20)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 5, 11)) +} + +function container() { +>container : Symbol(container, Decl(functionWithUseStrictAndSimpleParameterList.ts, 6, 1)) + + "use strict"; + function f(a = 10) { +>f : Symbol(f, Decl(functionWithUseStrictAndSimpleParameterList.ts, 9, 17)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 10, 15)) + } +} + +function rest(...args: any[]) { +>rest : Symbol(rest, Decl(functionWithUseStrictAndSimpleParameterList.ts, 12, 1)) +>args : Symbol(args, Decl(functionWithUseStrictAndSimpleParameterList.ts, 14, 14)) + + 'use strict'; +} + +function paramDefault(param = 1) { +>paramDefault : Symbol(paramDefault, Decl(functionWithUseStrictAndSimpleParameterList.ts, 16, 1)) +>param : Symbol(param, Decl(functionWithUseStrictAndSimpleParameterList.ts, 18, 22)) + + 'use strict'; +} + +function objectBindingPattern({foo}: any) { +>objectBindingPattern : Symbol(objectBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList.ts, 20, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 22, 31)) + + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { +>arrayBindingPattern : Symbol(arrayBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList.ts, 24, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 26, 30)) + + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { +>manyParameter : Symbol(manyParameter, Decl(functionWithUseStrictAndSimpleParameterList.ts, 28, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 30, 23)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 30, 30)) + + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { +>manyPrologue : Symbol(manyPrologue, Decl(functionWithUseStrictAndSimpleParameterList.ts, 32, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 34, 22)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 34, 29)) + + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { +>invalidPrologue : Symbol(invalidPrologue, Decl(functionWithUseStrictAndSimpleParameterList.ts, 37, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 39, 25)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 39, 32)) + + "foo"; + const c = 1; +>c : Symbol(c, Decl(functionWithUseStrictAndSimpleParameterList.ts, 41, 9)) + + "use strict"; +} + diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types new file mode 100644 index 00000000000..c64c3c30036 --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types @@ -0,0 +1,109 @@ +=== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts === +function a(a = 10) { +>a : (a?: number) => void +>a : number +>10 : 10 + + "use strict"; +>"use strict" : "use strict" +} + +export var foo = 10; +>foo : number +>10 : 10 + +function b(a = 10) { +>b : (a?: number) => void +>a : number +>10 : 10 +} + +function container() { +>container : () => void + + "use strict"; +>"use strict" : "use strict" + + function f(a = 10) { +>f : (a?: number) => void +>a : number +>10 : 10 + } +} + +function rest(...args: any[]) { +>rest : (...args: any[]) => void +>args : any[] + + 'use strict'; +>'use strict' : "use strict" +} + +function paramDefault(param = 1) { +>paramDefault : (param?: number) => void +>param : number +>1 : 1 + + 'use strict'; +>'use strict' : "use strict" +} + +function objectBindingPattern({foo}: any) { +>objectBindingPattern : ({ foo }: any) => void +>foo : any + + 'use strict'; +>'use strict' : "use strict" +} + +function arrayBindingPattern([foo]: any[]) { +>arrayBindingPattern : ([foo]: any[]) => void +>foo : any + + 'use strict'; +>'use strict' : "use strict" +} + +function manyParameter(a = 10, b = 20) { +>manyParameter : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "use strict"; +>"use strict" : "use strict" +} + +function manyPrologue(a = 10, b = 20) { +>manyPrologue : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "foo"; +>"foo" : "foo" + + "use strict"; +>"use strict" : "use strict" +} + +function invalidPrologue(a = 10, b = 20) { +>invalidPrologue : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "foo"; +>"foo" : "foo" + + const c = 1; +>c : 1 +>1 : 1 + + "use strict"; +>"use strict" : "use strict" +} + diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt new file mode 100644 index 00000000000..84d69721c61 --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt @@ -0,0 +1,114 @@ +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(1,12): error TS1344: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(2,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(15,15): error TS1344: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(16,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,23): error TS1344: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(20,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(23,31): error TS1344: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(24,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(27,30): error TS1344: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(28,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(31,24): error TS1344: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(31,32): error TS1344: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(32,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,23): error TS1344: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,31): error TS1344: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(37,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. + + +==== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts (16 errors) ==== + function a(a = 10) { + ~~~~~~ +!!! error TS1344: This parameter is not allowed with 'use strict' directive. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:2:5: use strict directive is here. + "use strict"; + ~~~~~~~~~~~~~ +!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:1:12: parameter is here. + } + + export var foo = 10; + function b(a = 10) { + } + + function container() { + "use strict"; + function f(a = 10) { + } + } + + function rest(...args: any[]) { + ~~~~~~~~~~~~~~ +!!! error TS1344: This parameter is not allowed with 'use strict' directive. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:16:5: use strict directive is here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:15:15: parameter is here. + } + + function paramDefault(param = 1) { + ~~~~~~~~~ +!!! error TS1344: This parameter is not allowed with 'use strict' directive. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: use strict directive is here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:19:23: parameter is here. + } + + function objectBindingPattern({foo}: any) { + ~~~~~~~~~~ +!!! error TS1344: This parameter is not allowed with 'use strict' directive. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:24:5: use strict directive is here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:23:31: parameter is here. + } + + function arrayBindingPattern([foo]: any[]) { + ~~~~~~~~~~~~ +!!! error TS1344: This parameter is not allowed with 'use strict' directive. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:28:5: use strict directive is here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:27:30: parameter is here. + } + + function manyParameter(a = 10, b = 20) { + ~~~~~~ +!!! error TS1344: This parameter is not allowed with 'use strict' directive. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:32:5: use strict directive is here. + ~~~~~~ +!!! error TS1344: This parameter is not allowed with 'use strict' directive. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:32:5: use strict directive is here. + "use strict"; + ~~~~~~~~~~~~~ +!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:31:24: parameter is here. +!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:31:32: and here. + } + + function manyPrologue(a = 10, b = 20) { + ~~~~~~ +!!! error TS1344: This parameter is not allowed with 'use strict' directive. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:37:5: use strict directive is here. + ~~~~~~ +!!! error TS1344: This parameter is not allowed with 'use strict' directive. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:37:5: use strict directive is here. + "foo"; + "use strict"; + ~~~~~~~~~~~~~ +!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. +!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:23: parameter is here. +!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:31: and here. + } + + function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; + } + \ No newline at end of file diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js new file mode 100644 index 00000000000..d8e50e9d1b6 --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js @@ -0,0 +1,83 @@ +//// [functionWithUseStrictAndSimpleParameterList_es2016.ts] +function a(a = 10) { + "use strict"; +} + +export var foo = 10; +function b(a = 10) { +} + +function container() { + "use strict"; + function f(a = 10) { + } +} + +function rest(...args: any[]) { + 'use strict'; +} + +function paramDefault(param = 1) { + 'use strict'; +} + +function objectBindingPattern({foo}: any) { + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} + + +//// [functionWithUseStrictAndSimpleParameterList_es2016.js] +function a(a = 10) { + "use strict"; +} +export var foo = 10; +function b(a = 10) { +} +function container() { + "use strict"; + function f(a = 10) { + } +} +function rest(...args) { + 'use strict'; +} +function paramDefault(param = 1) { + 'use strict'; +} +function objectBindingPattern({ foo }) { + 'use strict'; +} +function arrayBindingPattern([foo]) { + 'use strict'; +} +function manyParameter(a = 10, b = 20) { + "use strict"; +} +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols new file mode 100644 index 00000000000..444f219ab2f --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols @@ -0,0 +1,83 @@ +=== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts === +function a(a = 10) { +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 0, 0)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 0, 11)) + + "use strict"; +} + +export var foo = 10; +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 4, 10)) + +function b(a = 10) { +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 4, 20)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 5, 11)) +} + +function container() { +>container : Symbol(container, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 6, 1)) + + "use strict"; + function f(a = 10) { +>f : Symbol(f, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 9, 17)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 10, 15)) + } +} + +function rest(...args: any[]) { +>rest : Symbol(rest, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 12, 1)) +>args : Symbol(args, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 14, 14)) + + 'use strict'; +} + +function paramDefault(param = 1) { +>paramDefault : Symbol(paramDefault, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 16, 1)) +>param : Symbol(param, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 18, 22)) + + 'use strict'; +} + +function objectBindingPattern({foo}: any) { +>objectBindingPattern : Symbol(objectBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 20, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 22, 31)) + + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { +>arrayBindingPattern : Symbol(arrayBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 24, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 26, 30)) + + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { +>manyParameter : Symbol(manyParameter, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 28, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 30, 23)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 30, 30)) + + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { +>manyPrologue : Symbol(manyPrologue, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 32, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 34, 22)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 34, 29)) + + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { +>invalidPrologue : Symbol(invalidPrologue, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 37, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 39, 25)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 39, 32)) + + "foo"; + const c = 1; +>c : Symbol(c, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 41, 9)) + + "use strict"; +} + diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types new file mode 100644 index 00000000000..19f3d7f015b --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types @@ -0,0 +1,109 @@ +=== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts === +function a(a = 10) { +>a : (a?: number) => void +>a : number +>10 : 10 + + "use strict"; +>"use strict" : "use strict" +} + +export var foo = 10; +>foo : number +>10 : 10 + +function b(a = 10) { +>b : (a?: number) => void +>a : number +>10 : 10 +} + +function container() { +>container : () => void + + "use strict"; +>"use strict" : "use strict" + + function f(a = 10) { +>f : (a?: number) => void +>a : number +>10 : 10 + } +} + +function rest(...args: any[]) { +>rest : (...args: any[]) => void +>args : any[] + + 'use strict'; +>'use strict' : "use strict" +} + +function paramDefault(param = 1) { +>paramDefault : (param?: number) => void +>param : number +>1 : 1 + + 'use strict'; +>'use strict' : "use strict" +} + +function objectBindingPattern({foo}: any) { +>objectBindingPattern : ({ foo }: any) => void +>foo : any + + 'use strict'; +>'use strict' : "use strict" +} + +function arrayBindingPattern([foo]: any[]) { +>arrayBindingPattern : ([foo]: any[]) => void +>foo : any + + 'use strict'; +>'use strict' : "use strict" +} + +function manyParameter(a = 10, b = 20) { +>manyParameter : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "use strict"; +>"use strict" : "use strict" +} + +function manyPrologue(a = 10, b = 20) { +>manyPrologue : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "foo"; +>"foo" : "foo" + + "use strict"; +>"use strict" : "use strict" +} + +function invalidPrologue(a = 10, b = 20) { +>invalidPrologue : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "foo"; +>"foo" : "foo" + + const c = 1; +>c : 1 +>1 : 1 + + "use strict"; +>"use strict" : "use strict" +} + diff --git a/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts new file mode 100644 index 00000000000..65be76d500c --- /dev/null +++ b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts @@ -0,0 +1,44 @@ +function a(a = 10) { + "use strict"; +} + +export var foo = 10; +function b(a = 10) { +} + +function container() { + "use strict"; + function f(a = 10) { + } +} + +function rest(...args: any[]) { + 'use strict'; +} + +function paramDefault(param = 1) { + 'use strict'; +} + +function objectBindingPattern({foo}: any) { + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} diff --git a/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts new file mode 100644 index 00000000000..ed17746931a --- /dev/null +++ b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts @@ -0,0 +1,46 @@ +// @target: es2016 + +function a(a = 10) { + "use strict"; +} + +export var foo = 10; +function b(a = 10) { +} + +function container() { + "use strict"; + function f(a = 10) { + } +} + +function rest(...args: any[]) { + 'use strict'; +} + +function paramDefault(param = 1) { + 'use strict'; +} + +function objectBindingPattern({foo}: any) { + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} From 02f5365e080686c9b89b3dc55abf27267eaf2a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Wed, 1 Aug 2018 10:21:50 +0800 Subject: [PATCH 2/3] improve error message and update testcase --- src/compiler/checker.ts | 15 +-- src/compiler/diagnosticMessages.json | 8 +- ...tionWithUseStrictAndSimpleParameterList.js | 12 ++ ...ithUseStrictAndSimpleParameterList.symbols | 40 +++--- ...nWithUseStrictAndSimpleParameterList.types | 10 ++ ...ctAndSimpleParameterList_es2016.errors.txt | 119 ++++++++++-------- ...hUseStrictAndSimpleParameterList_es2016.js | 7 ++ ...trictAndSimpleParameterList_es2016.symbols | 40 +++--- ...eStrictAndSimpleParameterList_es2016.types | 10 ++ ...tionWithUseStrictAndSimpleParameterList.ts | 4 + ...hUseStrictAndSimpleParameterList_es2016.ts | 4 + 11 files changed, 172 insertions(+), 97 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index de9521031f6..eaf18a5078f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28717,16 +28717,7 @@ namespace ts { } function getNonSimpleParameters(parameters: ReadonlyArray): ReadonlyArray { - // ECMA-262 14.1.13 - if (parameters.length === 0) return []; - - const last = lastOrUndefined(parameters); - if (last && isRestParameter(last)) return [last]; - - return filter(parameters, parameter => { - // ECMA-262 13.3.3.4 - return !!parameter.initializer || isBindingPattern(parameter.name); - }); + return filter(parameters, parameter => !!parameter.initializer || isBindingPattern(parameter.name) || isRestParameter(parameter)); } function checkGrammarForUseStrictSimpleParameterList(node: FunctionLikeDeclaration): boolean { @@ -28738,12 +28729,12 @@ namespace ts { forEach(nonSimpleParameters, parameter => { addRelatedInfo( error(parameter, Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), - createDiagnosticForNode(useStrictDirective, Diagnostics._0_is_here, "use strict directive") + createDiagnosticForNode(useStrictDirective, Diagnostics.use_strict_directive_used_here) ); }); const diagnostics = nonSimpleParameters.map((parameter, index) => ( - index === 0 ? createDiagnosticForNode(parameter, Diagnostics._0_is_here, "parameter") : createDiagnosticForNode(parameter, Diagnostics.and_here) + index === 0 ? createDiagnosticForNode(parameter, Diagnostics.Non_simple_parameter_declared_here) : createDiagnosticForNode(parameter, Diagnostics.and_here) )) as [DiagnosticWithLocation, ...DiagnosticWithLocation[]]; addRelatedInfo(error(useStrictDirective, Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list), ...diagnostics); return true; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0831ab7fba2..0a35bb0e85b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -991,14 +991,18 @@ "category": "Error", "code": 1345 }, - "'use strict' directive cannot be used with non simple parameter list.": { + "'use strict' directive cannot be used with non-simple parameter list.": { "category": "Error", "code": 1346 }, - "{0} is here.": { + "Non-simple parameter declared here.": { "category": "Error", "code": 1347 }, + "'use strict' directive used here.": { + "category": "Error", + "code": 1348 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js index 260f0df874a..1cf35579976 100644 --- a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js @@ -17,6 +17,10 @@ function rest(...args: any[]) { 'use strict'; } +function rest1(a = 1, ...args) { + 'use strict'; +} + function paramDefault(param = 1) { 'use strict'; } @@ -69,6 +73,14 @@ function rest() { args[_i] = arguments[_i]; } } +function rest1(a) { + 'use strict'; + if (a === void 0) { a = 1; } + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } +} function paramDefault(param) { 'use strict'; if (param === void 0) { param = 1; } diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols index 59c8190883f..9c2ad86d974 100644 --- a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols @@ -31,52 +31,60 @@ function rest(...args: any[]) { 'use strict'; } +function rest1(a = 1, ...args) { +>rest1 : Symbol(rest1, Decl(functionWithUseStrictAndSimpleParameterList.ts, 16, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 18, 15)) +>args : Symbol(args, Decl(functionWithUseStrictAndSimpleParameterList.ts, 18, 21)) + + 'use strict'; +} + function paramDefault(param = 1) { ->paramDefault : Symbol(paramDefault, Decl(functionWithUseStrictAndSimpleParameterList.ts, 16, 1)) ->param : Symbol(param, Decl(functionWithUseStrictAndSimpleParameterList.ts, 18, 22)) +>paramDefault : Symbol(paramDefault, Decl(functionWithUseStrictAndSimpleParameterList.ts, 20, 1)) +>param : Symbol(param, Decl(functionWithUseStrictAndSimpleParameterList.ts, 22, 22)) 'use strict'; } function objectBindingPattern({foo}: any) { ->objectBindingPattern : Symbol(objectBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList.ts, 20, 1)) ->foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 22, 31)) +>objectBindingPattern : Symbol(objectBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList.ts, 24, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 26, 31)) 'use strict'; } function arrayBindingPattern([foo]: any[]) { ->arrayBindingPattern : Symbol(arrayBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList.ts, 24, 1)) ->foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 26, 30)) +>arrayBindingPattern : Symbol(arrayBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList.ts, 28, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 30, 30)) 'use strict'; } function manyParameter(a = 10, b = 20) { ->manyParameter : Symbol(manyParameter, Decl(functionWithUseStrictAndSimpleParameterList.ts, 28, 1)) ->a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 30, 23)) ->b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 30, 30)) +>manyParameter : Symbol(manyParameter, Decl(functionWithUseStrictAndSimpleParameterList.ts, 32, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 34, 23)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 34, 30)) "use strict"; } function manyPrologue(a = 10, b = 20) { ->manyPrologue : Symbol(manyPrologue, Decl(functionWithUseStrictAndSimpleParameterList.ts, 32, 1)) ->a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 34, 22)) ->b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 34, 29)) +>manyPrologue : Symbol(manyPrologue, Decl(functionWithUseStrictAndSimpleParameterList.ts, 36, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 38, 22)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 38, 29)) "foo"; "use strict"; } function invalidPrologue(a = 10, b = 20) { ->invalidPrologue : Symbol(invalidPrologue, Decl(functionWithUseStrictAndSimpleParameterList.ts, 37, 1)) ->a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 39, 25)) ->b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 39, 32)) +>invalidPrologue : Symbol(invalidPrologue, Decl(functionWithUseStrictAndSimpleParameterList.ts, 41, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 43, 25)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 43, 32)) "foo"; const c = 1; ->c : Symbol(c, Decl(functionWithUseStrictAndSimpleParameterList.ts, 41, 9)) +>c : Symbol(c, Decl(functionWithUseStrictAndSimpleParameterList.ts, 45, 9)) "use strict"; } diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types index c64c3c30036..462086d28ad 100644 --- a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types @@ -39,6 +39,16 @@ function rest(...args: any[]) { >'use strict' : "use strict" } +function rest1(a = 1, ...args) { +>rest1 : (a?: number, ...args: any[]) => void +>a : number +>1 : 1 +>args : any[] + + 'use strict'; +>'use strict' : "use strict" +} + function paramDefault(param = 1) { >paramDefault : (param?: number) => void >param : number diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt index 84d69721c61..4887cb4f07a 100644 --- a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt @@ -1,30 +1,33 @@ -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(1,12): error TS1344: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(2,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(15,15): error TS1344: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(16,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,23): error TS1344: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(20,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(23,31): error TS1344: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(24,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(27,30): error TS1344: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(28,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(31,24): error TS1344: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(31,32): error TS1344: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(32,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,23): error TS1344: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,31): error TS1344: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(37,5): error TS1345: 'use strict' directive cannot be used with non simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(1,12): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(2,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(15,15): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(16,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,16): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,23): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(20,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(23,23): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(24,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(27,31): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(28,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(31,30): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(32,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,24): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,32): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(36,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(39,23): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(39,31): error TS1345: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(41,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -==== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts (16 errors) ==== +==== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts (19 errors) ==== function a(a = 10) { ~~~~~~ -!!! error TS1344: This parameter is not allowed with 'use strict' directive. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:2:5: use strict directive is here. +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:2:5: 'use strict' directive used here. "use strict"; ~~~~~~~~~~~~~ -!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:1:12: parameter is here. +!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:1:12: Non-simple parameter declared here. } export var foo = 10; @@ -39,71 +42,85 @@ tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es function rest(...args: any[]) { ~~~~~~~~~~~~~~ -!!! error TS1344: This parameter is not allowed with 'use strict' directive. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:16:5: use strict directive is here. +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:16:5: 'use strict' directive used here. 'use strict'; ~~~~~~~~~~~~~ -!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:15:15: parameter is here. +!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:15:15: Non-simple parameter declared here. + } + + function rest1(a = 1, ...args) { + ~~~~~ +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: 'use strict' directive used here. + ~~~~~~~ +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: 'use strict' directive used here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:19:16: Non-simple parameter declared here. +!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:19:23: and here. } function paramDefault(param = 1) { ~~~~~~~~~ -!!! error TS1344: This parameter is not allowed with 'use strict' directive. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: use strict directive is here. +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:24:5: 'use strict' directive used here. 'use strict'; ~~~~~~~~~~~~~ -!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:19:23: parameter is here. +!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:23:23: Non-simple parameter declared here. } function objectBindingPattern({foo}: any) { ~~~~~~~~~~ -!!! error TS1344: This parameter is not allowed with 'use strict' directive. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:24:5: use strict directive is here. +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:28:5: 'use strict' directive used here. 'use strict'; ~~~~~~~~~~~~~ -!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:23:31: parameter is here. +!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:27:31: Non-simple parameter declared here. } function arrayBindingPattern([foo]: any[]) { ~~~~~~~~~~~~ -!!! error TS1344: This parameter is not allowed with 'use strict' directive. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:28:5: use strict directive is here. +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:32:5: 'use strict' directive used here. 'use strict'; ~~~~~~~~~~~~~ -!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:27:30: parameter is here. +!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:31:30: Non-simple parameter declared here. } function manyParameter(a = 10, b = 20) { ~~~~~~ -!!! error TS1344: This parameter is not allowed with 'use strict' directive. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:32:5: use strict directive is here. +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:36:5: 'use strict' directive used here. ~~~~~~ -!!! error TS1344: This parameter is not allowed with 'use strict' directive. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:32:5: use strict directive is here. +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:36:5: 'use strict' directive used here. "use strict"; ~~~~~~~~~~~~~ -!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:31:24: parameter is here. -!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:31:32: and here. +!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:24: Non-simple parameter declared here. +!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:32: and here. } function manyPrologue(a = 10, b = 20) { ~~~~~~ -!!! error TS1344: This parameter is not allowed with 'use strict' directive. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:37:5: use strict directive is here. +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:41:5: 'use strict' directive used here. ~~~~~~ -!!! error TS1344: This parameter is not allowed with 'use strict' directive. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:37:5: use strict directive is here. +!!! error TS1345: This parameter is not allowed with 'use strict' directive. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:41:5: 'use strict' directive used here. "foo"; "use strict"; ~~~~~~~~~~~~~ -!!! error TS1345: 'use strict' directive cannot be used with non simple parameter list. -!!! related TS1346 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:23: parameter is here. -!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:31: and here. +!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:39:23: Non-simple parameter declared here. +!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:39:31: and here. } function invalidPrologue(a = 10, b = 20) { diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js index d8e50e9d1b6..f9e07fc96ea 100644 --- a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js @@ -17,6 +17,10 @@ function rest(...args: any[]) { 'use strict'; } +function rest1(a = 1, ...args) { + 'use strict'; +} + function paramDefault(param = 1) { 'use strict'; } @@ -60,6 +64,9 @@ function container() { function rest(...args) { 'use strict'; } +function rest1(a = 1, ...args) { + 'use strict'; +} function paramDefault(param = 1) { 'use strict'; } diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols index 444f219ab2f..8f3d1366ad2 100644 --- a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols @@ -31,52 +31,60 @@ function rest(...args: any[]) { 'use strict'; } +function rest1(a = 1, ...args) { +>rest1 : Symbol(rest1, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 16, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 18, 15)) +>args : Symbol(args, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 18, 21)) + + 'use strict'; +} + function paramDefault(param = 1) { ->paramDefault : Symbol(paramDefault, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 16, 1)) ->param : Symbol(param, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 18, 22)) +>paramDefault : Symbol(paramDefault, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 20, 1)) +>param : Symbol(param, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 22, 22)) 'use strict'; } function objectBindingPattern({foo}: any) { ->objectBindingPattern : Symbol(objectBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 20, 1)) ->foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 22, 31)) +>objectBindingPattern : Symbol(objectBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 24, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 26, 31)) 'use strict'; } function arrayBindingPattern([foo]: any[]) { ->arrayBindingPattern : Symbol(arrayBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 24, 1)) ->foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 26, 30)) +>arrayBindingPattern : Symbol(arrayBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 28, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 30, 30)) 'use strict'; } function manyParameter(a = 10, b = 20) { ->manyParameter : Symbol(manyParameter, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 28, 1)) ->a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 30, 23)) ->b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 30, 30)) +>manyParameter : Symbol(manyParameter, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 32, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 34, 23)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 34, 30)) "use strict"; } function manyPrologue(a = 10, b = 20) { ->manyPrologue : Symbol(manyPrologue, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 32, 1)) ->a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 34, 22)) ->b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 34, 29)) +>manyPrologue : Symbol(manyPrologue, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 36, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 38, 22)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 38, 29)) "foo"; "use strict"; } function invalidPrologue(a = 10, b = 20) { ->invalidPrologue : Symbol(invalidPrologue, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 37, 1)) ->a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 39, 25)) ->b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 39, 32)) +>invalidPrologue : Symbol(invalidPrologue, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 41, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 43, 25)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 43, 32)) "foo"; const c = 1; ->c : Symbol(c, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 41, 9)) +>c : Symbol(c, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 45, 9)) "use strict"; } diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types index 19f3d7f015b..c5268cd8e48 100644 --- a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types @@ -39,6 +39,16 @@ function rest(...args: any[]) { >'use strict' : "use strict" } +function rest1(a = 1, ...args) { +>rest1 : (a?: number, ...args: any[]) => void +>a : number +>1 : 1 +>args : any[] + + 'use strict'; +>'use strict' : "use strict" +} + function paramDefault(param = 1) { >paramDefault : (param?: number) => void >param : number diff --git a/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts index 65be76d500c..d4b8ced9b42 100644 --- a/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts +++ b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts @@ -16,6 +16,10 @@ function rest(...args: any[]) { 'use strict'; } +function rest1(a = 1, ...args) { + 'use strict'; +} + function paramDefault(param = 1) { 'use strict'; } diff --git a/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts index ed17746931a..6c9fadd1ac1 100644 --- a/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts +++ b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts @@ -18,6 +18,10 @@ function rest(...args: any[]) { 'use strict'; } +function rest1(a = 1, ...args) { + 'use strict'; +} + function paramDefault(param = 1) { 'use strict'; } From 0d3adffd1a87bec80e36feda4caad3638ff28b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Wed, 29 Aug 2018 18:42:02 +0800 Subject: [PATCH 3/3] accept baseline --- ...ctAndSimpleParameterList_es2016.errors.txt | 114 +++++++++--------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt index 4887cb4f07a..4f92ac06b2b 100644 --- a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt @@ -1,33 +1,33 @@ -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(1,12): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(2,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(15,15): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(16,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,16): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,23): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(20,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(23,23): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(24,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(27,31): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(28,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(31,30): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(32,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,24): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,32): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(36,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(39,23): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(39,31): error TS1345: This parameter is not allowed with 'use strict' directive. -tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(41,5): error TS1346: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(1,12): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(2,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(15,15): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(16,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,16): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,23): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(20,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(23,23): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(24,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(27,31): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(28,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(31,30): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(32,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,24): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,32): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(36,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(39,23): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(39,31): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(41,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. ==== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts (19 errors) ==== function a(a = 10) { ~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:2:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:2:5: 'use strict' directive used here. "use strict"; ~~~~~~~~~~~~~ -!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:1:12: Non-simple parameter declared here. +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:1:12: Non-simple parameter declared here. } export var foo = 10; @@ -42,84 +42,84 @@ tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es function rest(...args: any[]) { ~~~~~~~~~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:16:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:16:5: 'use strict' directive used here. 'use strict'; ~~~~~~~~~~~~~ -!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:15:15: Non-simple parameter declared here. +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:15:15: Non-simple parameter declared here. } function rest1(a = 1, ...args) { ~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: 'use strict' directive used here. ~~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: 'use strict' directive used here. 'use strict'; ~~~~~~~~~~~~~ -!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:19:16: Non-simple parameter declared here. +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:19:16: Non-simple parameter declared here. !!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:19:23: and here. } function paramDefault(param = 1) { ~~~~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:24:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:24:5: 'use strict' directive used here. 'use strict'; ~~~~~~~~~~~~~ -!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:23:23: Non-simple parameter declared here. +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:23:23: Non-simple parameter declared here. } function objectBindingPattern({foo}: any) { ~~~~~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:28:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:28:5: 'use strict' directive used here. 'use strict'; ~~~~~~~~~~~~~ -!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:27:31: Non-simple parameter declared here. +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:27:31: Non-simple parameter declared here. } function arrayBindingPattern([foo]: any[]) { ~~~~~~~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:32:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:32:5: 'use strict' directive used here. 'use strict'; ~~~~~~~~~~~~~ -!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:31:30: Non-simple parameter declared here. +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:31:30: Non-simple parameter declared here. } function manyParameter(a = 10, b = 20) { ~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:36:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:36:5: 'use strict' directive used here. ~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:36:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:36:5: 'use strict' directive used here. "use strict"; ~~~~~~~~~~~~~ -!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:24: Non-simple parameter declared here. +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:24: Non-simple parameter declared here. !!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:32: and here. } function manyPrologue(a = 10, b = 20) { ~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:41:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:41:5: 'use strict' directive used here. ~~~~~~ -!!! error TS1345: This parameter is not allowed with 'use strict' directive. -!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:41:5: 'use strict' directive used here. +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:41:5: 'use strict' directive used here. "foo"; "use strict"; ~~~~~~~~~~~~~ -!!! error TS1346: 'use strict' directive cannot be used with non-simple parameter list. -!!! related TS1347 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:39:23: Non-simple parameter declared here. +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:39:23: Non-simple parameter declared here. !!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:39:31: and here. }