Skip to content

Should the strict-mode status of a file be dependent on its external module status #4963

Closed
@weswigham

Description

@weswigham

With #4811 merged we've decoupled ES6 module emit from the ES6 language level, allowing us to emit other module forms when targeting ES6. This brings up another interesting question - we parse all external modules in strict mode, ES6 or not, when this is only a requirement for ES6 modules. Should we fix this and make the parse dependent on the module selection? Or should we emit "use strict"; in non-ES6 forms so reality matches the parser? Even before #4811 we've actually had this wrong:

import * as foo from "./foo";

with (foo) {

}

We forbid the with as per strict mode, but we're emitting an amd module without a "use strict"; indicator. To be correct, when not targeting es6 modules, we should either disable strict mode when parsing or emit a "use strict";.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions