Skip to content
This repository was archived by the owner on Jul 30, 2018. It is now read-only.
This repository was archived by the owner on Jul 30, 2018. It is now read-only.

Type global #100

@kitsonk

Description

@kitsonk

Enhancement

This is one of the most dangerous parts of Dojo 2 at the moment. Our shim/global module is untyped. This can lead to a lot of issues at design time, as well as poor practices when the global namespace is touched by modules.

I would like to propose that we type it with an interface which could be extended if necessary that extends Window since most global we want to access are already available there.

Any need to access other types in the global would ideally use module interface augmentation.
Since 1.8 you are able to do module interface augmentation. It would look something like this:

import global from '@dojo/shim/global';

declare module '@dojo/shim/global' {
  interface Global {
    SOME_GLOBAL_CONST: 'some-literal-value';
  }
}

console.log(global.SOME_GLOBAL_CONST);

This would be a breaking change, where anyone is accessing global variables that don't have type information, and therefore are automatically being typed as any, but obviously this is a safer long term approach to accessing the global scope.

Package Version: beta2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions