Skip to content

Language: Deprecate implicit imports and hidden globals #125

@wcjohnson

Description

@wcjohnson

As a start to ushering in a cleaner language for static analysis/merging with TypeScript, my objective is to clean up areas where there is implicit or hidden pollution of globals. This involves the following steps:

Deprecate Lightscript stdlib/Lodash implicit imports

  • Non-breaking stdlib deprecation path
  • { stdlib: false } is now a default option
  • Those wanting old behavior can set { stdlib: true } in compiler config

Deprecate implicit global operators

  • looseEq, looseNotEq, bitwise* implicit globals will be removed
  • Those desiring old behavior can set { implicitGlobalOperators: true } in compiler opts
  • Option removed altogether in 5.x
  • Instead, import { looseEq, ... } from '@lightscript/lang' at top level
  • Compiler will detect this and treat it as a virtual import, replacing with compiled code
  • A nonce module will be published to npm as @lightscript/lang to aid with static analysis

Deprecate implicit lightscript runtime imports

  • @lightscript/runtime will no longer be implicitly imported
  • Those desiring old behavior can set { implicitRuntime: true } in compiler opts
  • Option removed altogether in 5.x
  • When the compiler encounters a construct requiring the runtime, it will check for import runtime from '@lightscript/runtime' at top level
  • If the runtime is not imported, an error is thrown
  • A lint rule will be added to check for constructs that require the runtime

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions