* Returns whether the source file will be treated as if it were in strict mode at runtime.
(node, compilerOptions)
| 15053 | * Returns whether the source file will be treated as if it were in strict mode at runtime. |
| 15054 | */ |
| 15055 | function isEffectiveStrictModeSourceFile(node, compilerOptions) { |
| 15056 | // We can only verify strict mode for JS/TS files |
| 15057 | switch (node.scriptKind) { |
| 15058 | case 1 /* ScriptKind.JS */: |
| 15059 | case 3 /* ScriptKind.TS */: |
| 15060 | case 2 /* ScriptKind.JSX */: |
| 15061 | case 4 /* ScriptKind.TSX */: |
| 15062 | break; |
| 15063 | default: |
| 15064 | return false; |
| 15065 | } |
| 15066 | // Strict mode does not matter for declaration files. |
| 15067 | if (node.isDeclarationFile) { |
| 15068 | return false; |
| 15069 | } |
| 15070 | // If `alwaysStrict` is set, then treat the file as strict. |
| 15071 | if (getStrictOptionValue(compilerOptions, "alwaysStrict")) { |
| 15072 | return true; |
| 15073 | } |
| 15074 | // Starting with a "use strict" directive indicates the file is strict. |
| 15075 | if (ts.startsWithUseStrict(node.statements)) { |
| 15076 | return true; |
| 15077 | } |
| 15078 | if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { |
| 15079 | // ECMAScript Modules are always strict. |
| 15080 | if (getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { |
| 15081 | return true; |
| 15082 | } |
| 15083 | // Other modules are strict unless otherwise specified. |
| 15084 | return !compilerOptions.noImplicitUseStrict; |
| 15085 | } |
| 15086 | return false; |
| 15087 | } |
| 15088 | ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; |
| 15089 | function isBlockScope(node, parentNode) { |
| 15090 | switch (node.kind) { |
nothing calls this directly
no test coverage detected