MCPcopy Index your code
hub / github.com/nodejs/node / checkStrictModeFunctionDeclaration

Function checkStrictModeFunctionDeclaration

test/fixtures/snapshot/typescript.js:46660–46672  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

46658 return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
46659 }
46660 function checkStrictModeFunctionDeclaration(node) {
46661 if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
46662 // Report error if function is not top level function declaration
46663 if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ &&
46664 blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ &&
46665 !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) {
46666 // We check first if the name is inside class declaration or class expression; if so give explicit message
46667 // otherwise report generic error message.
46668 var errorSpan = ts.getErrorSpanForNode(file, node);
46669 file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node)));
46670 }
46671 }
46672 }
46673 function checkStrictModeNumericLiteral(node) {
46674 if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) {
46675 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));

Callers 1

bindFunctionDeclarationFunction · 0.85

Calls 2

pushMethod · 0.45

Tested by

no test coverage detected