mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Merge pull request #7925 from Microsoft/correctStrictPrologueCheckToTransforms
Correct strict prologue check to transforms
This commit is contained in:
commit
4446727fa6
@ -7636,7 +7636,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
function isUseStrictPrologue(node: ExpressionStatement): boolean {
|
||||
return !!(node.expression as StringLiteral).text.match(/use strict/);
|
||||
return (node.expression as StringLiteral).text === "use strict";
|
||||
}
|
||||
|
||||
function ensureUseStrictPrologue(startWithNewLine: boolean, writeUseStrict: boolean) {
|
||||
|
||||
@ -1202,7 +1202,7 @@ namespace ts {
|
||||
// Utilities
|
||||
|
||||
function isUseStrictPrologue(node: ExpressionStatement): boolean {
|
||||
return !!(node.expression as StringLiteral).text.match(/use strict/);
|
||||
return (node.expression as StringLiteral).text === "use strict";
|
||||
}
|
||||
|
||||
export function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean): number {
|
||||
|
||||
14
tests/baselines/reference/useStrictLikePrologueString01.js
Normal file
14
tests/baselines/reference/useStrictLikePrologueString01.js
Normal file
@ -0,0 +1,14 @@
|
||||
//// [useStrictLikePrologueString01.ts]
|
||||
|
||||
"hey!"
|
||||
" use strict "
|
||||
export function f() {
|
||||
}
|
||||
|
||||
//// [useStrictLikePrologueString01.js]
|
||||
"hey!";
|
||||
" use strict ";
|
||||
"use strict";
|
||||
function f() {
|
||||
}
|
||||
exports.f = f;
|
||||
@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/useStrictLikePrologueString01.ts ===
|
||||
|
||||
"hey!"
|
||||
" use strict "
|
||||
export function f() {
|
||||
>f : Symbol(f, Decl(useStrictLikePrologueString01.ts, 2, 14))
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
=== tests/cases/compiler/useStrictLikePrologueString01.ts ===
|
||||
|
||||
"hey!"
|
||||
>"hey!" : string
|
||||
|
||||
" use strict "
|
||||
>" use strict " : string
|
||||
|
||||
export function f() {
|
||||
>f : () => void
|
||||
}
|
||||
7
tests/cases/compiler/useStrictLikePrologueString01.ts
Normal file
7
tests/cases/compiler/useStrictLikePrologueString01.ts
Normal file
@ -0,0 +1,7 @@
|
||||
//@target: commonjs
|
||||
//@target: es5
|
||||
|
||||
"hey!"
|
||||
" use strict "
|
||||
export function f() {
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user