Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ namespace ts {
name: "allowJs",
type: "boolean",
description: Diagnostics.Allow_javascript_files_to_be_compiled
},
{
name: "noImplicitUseStrict",
type: "boolean",
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
}
];

Expand Down
37 changes: 21 additions & 16 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"Unterminated string literal.": {
"category": "Error",
"code": 1002
Expand Down Expand Up @@ -2171,6 +2171,7 @@
"category": "Error",
"code": 5059
},


"Concatenate and emit output to single file.": {
"category": "Message",
Expand Down Expand Up @@ -2216,10 +2217,10 @@
"category": "Message",
"code": 6011
},
"Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)": {
"category": "Message",
"code": 6015
},
"Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)": {
"category": "Message",
"code": 6015
},
"Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'": {
"category": "Message",
"code": 6016
Expand Down Expand Up @@ -2445,6 +2446,10 @@
"category": "Message",
"code": 6084
},
"Do not emit 'use strict' directives in module output.": {
"category": "Message",
"code": 6112
},

"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
Expand Down Expand Up @@ -2632,23 +2637,23 @@
"code": 17004
},
"A constructor cannot contain a 'super' call when its class extends 'null'": {
"category": "Error",
"code": 17005
"category": "Error",
"code": 17005
},
"An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": {
"category": "Error",
"code": 17006
"category": "Error",
"code": 17006
},
"A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": {
"category": "Error",
"code": 17007
"category": "Error",
"code": 17007
},
"JSX element '{0}' has no corresponding closing tag.": {
"category": "Error",
"code": 17008
"category": "Error",
"code": 17008
},
"'super' must be called before accessing 'this' in the constructor of a derived class.": {
"category": "Error",
"code": 17009
"category": "Error",
"code": 17009
}
}
}
8 changes: 4 additions & 4 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7268,7 +7268,7 @@ const _super = (function (geti, seti) {
write(`], function(${exportFunctionForFile}, ${contextObjectForFile}) {`);
writeLine();
increaseIndent();
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
writeLine();
write(`var __moduleName = ${contextObjectForFile} && ${contextObjectForFile}.id;`);
writeLine();
Expand Down Expand Up @@ -7374,7 +7374,7 @@ const _super = (function (geti, seti) {
writeModuleName(node, emitRelativePathAsModuleName);
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName);
increaseIndent();
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/!compilerOptions.noImplicitUseStrict);
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
Expand All @@ -7386,7 +7386,7 @@ const _super = (function (geti, seti) {
}

function emitCommonJSModule(node: SourceFile) {
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ true);
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
emitEmitHelpers(node);
collectExternalModuleInfo(node);
emitExportStarHelper();
Expand Down Expand Up @@ -7415,7 +7415,7 @@ const _super = (function (geti, seti) {
})(`);
emitAMDFactoryHeader(dependencyNames);
increaseIndent();
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
Expand Down
1 change: 1 addition & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,7 @@ namespace ts {
forceConsistentCasingInFileNames?: boolean;
allowSyntheticDefaultImports?: boolean;
allowJs?: boolean;
noImplicitUseStrict?: boolean;
/* @internal */ stripInternal?: boolean;

// Skip checking lib.d.ts to help speed up tests.
Expand Down
8 changes: 8 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_amd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//// [noImplicitUseStrict_amd.ts]

export var x = 0;

//// [noImplicitUseStrict_amd.js]
define(["require", "exports"], function (require, exports) {
exports.x = 0;
});
5 changes: 5 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_amd.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/compiler/noImplicitUseStrict_amd.ts ===

export var x = 0;
>x : Symbol(x, Decl(noImplicitUseStrict_amd.ts, 1, 10))

6 changes: 6 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_amd.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=== tests/cases/compiler/noImplicitUseStrict_amd.ts ===

export var x = 0;
>x : number
>0 : number

6 changes: 6 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_commonjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [noImplicitUseStrict_commonjs.ts]

export var x = 0;

//// [noImplicitUseStrict_commonjs.js]
exports.x = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/compiler/noImplicitUseStrict_commonjs.ts ===

export var x = 0;
>x : Symbol(x, Decl(noImplicitUseStrict_commonjs.ts, 1, 10))

6 changes: 6 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_commonjs.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=== tests/cases/compiler/noImplicitUseStrict_commonjs.ts ===

export var x = 0;
>x : number
>0 : number

6 changes: 6 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [noImplicitUseStrict_es6.ts]

export var x = 0;

//// [noImplicitUseStrict_es6.js]
export var x = 0;
5 changes: 5 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_es6.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/compiler/noImplicitUseStrict_es6.ts ===

export var x = 0;
>x : Symbol(x, Decl(noImplicitUseStrict_es6.ts, 1, 10))

6 changes: 6 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_es6.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=== tests/cases/compiler/noImplicitUseStrict_es6.ts ===

export var x = 0;
>x : number
>0 : number

15 changes: 15 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_system.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//// [noImplicitUseStrict_system.ts]

export var x = 0;

//// [noImplicitUseStrict_system.js]
System.register([], function(exports_1, context_1) {
var __moduleName = context_1 && context_1.id;
var x;
return {
setters:[],
execute: function() {
exports_1("x", x = 0);
}
}
});
5 changes: 5 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_system.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/compiler/noImplicitUseStrict_system.ts ===

export var x = 0;
>x : Symbol(x, Decl(noImplicitUseStrict_system.ts, 1, 10))

6 changes: 6 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_system.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=== tests/cases/compiler/noImplicitUseStrict_system.ts ===

export var x = 0;
>x : number
>0 : number

15 changes: 15 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_umd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//// [noImplicitUseStrict_umd.ts]

export var x = 0;

//// [noImplicitUseStrict_umd.js]
(function (factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
exports.x = 0;
});
5 changes: 5 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_umd.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/compiler/noImplicitUseStrict_umd.ts ===

export var x = 0;
>x : Symbol(x, Decl(noImplicitUseStrict_umd.ts, 1, 10))

6 changes: 6 additions & 0 deletions tests/baselines/reference/noImplicitUseStrict_umd.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=== tests/cases/compiler/noImplicitUseStrict_umd.ts ===

export var x = 0;
>x : number
>0 : number

4 changes: 4 additions & 0 deletions tests/cases/compiler/noImplicitUseStrict_amd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @module: amd
// @noImplicitUseStrict: true

export var x = 0;
4 changes: 4 additions & 0 deletions tests/cases/compiler/noImplicitUseStrict_commonjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @module: commonjs
// @noImplicitUseStrict: true

export var x = 0;
5 changes: 5 additions & 0 deletions tests/cases/compiler/noImplicitUseStrict_es6.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @module: es6
// @target: es6
// @noImplicitUseStrict: true

export var x = 0;
4 changes: 4 additions & 0 deletions tests/cases/compiler/noImplicitUseStrict_system.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @module: system
// @noImplicitUseStrict: true

export var x = 0;
4 changes: 4 additions & 0 deletions tests/cases/compiler/noImplicitUseStrict_umd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @module: umd
// @noImplicitUseStrict: true

export var x = 0;