In the discussion on #328 the consensus seems to be that people like type definitions. This moves toward generating types using jsdoc as suggested by @bollwyvl in that thread.

I don't have much Typescript experience so I would very much appreciate it if people could test them out. The types are available as CircleCI artifacts here:
https://3914-322074228-gh.circle-artifacts.com/0/root/repo/build/pyodide.d.ts

@bollwyvl said that

> types that aren't tested are probably worse than no types at all

If anyone could contribute tests, that would be very helpful (I don't know what they should look like). 

The main limitation I ran into with this approach is that Typescript supports Typescript types in jsdoc annotations but jsdoc does not. This means that if we want to automatically generate docs, we have to stick to the much more limited syntax that jsdoc supports. For example, `isPyProxy` should be typed `obj is PyProxy` but this approach does not allow that as far as I can tell. 
Some basic types. In the discussion on #328 the consensus seems to be that people like type definitions. This moves toward generating types using jsdoc as suggested by @bollwyvl in that thread.

I don't have much Typescript experience so I would very much appreciate it if people could test them out. The types are available as CircleCI artifacts here:
https://3914-322074228-gh.circle-artifacts.com/0/root/repo/build/pyodide.d.ts

@bollwyvl said that

> types that aren't tested are probably worse than no types at all

If anyone could contribute tests, that would be very helpful (I don't know what they should look like). 

The main limitation I ran into with this approach is that Typescript supports Typescript types in jsdoc annotations but jsdoc does not. This means that if we want to automatically generate docs, we have to stick to the much more limited syntax that jsdoc supports. For example, `isPyProxy` should be typed `obj is PyProxy` but this approach does not allow that as far as I can tell. 
import sys
from pathlib import Path

sys.path.append(str(Path(__file__).parents[2]))

from pyodide_build.common import (
    _parse_package_subset,
    get_make_flag,
    get_make_environment_vars,
)  # noqa


def test_parse_package_subset():
    assert _parse_package_subset(None) is None
    # micropip is always included
    assert _parse_package_subset("numpy,pandas") == {
        "pyparsing",
        "packaging",
        "micropip",
        "numpy",
        "pandas",
    }

    # duplicates are removed
    assert _parse_package_subset("numpy,numpy") == {
        "pyparsing",
        "packaging",
        "micropip",
        "numpy",
    }

    # no empty package name included, spaces are handled
    assert _parse_package_subset("x,  a, b, c   ,,, d,,") == {
        "pyparsing",
        "packaging",
        "micropip",
        "x",
        "a",
        "b",
        "c",
        "d",
    }


def test_get_make_flag():
    assert len(get_make_flag("SIDE_MODULE_LDFLAGS")) > 0
    assert len(get_make_flag("SIDE_MODULE_CFLAGS")) > 0
    # n.b. right now CXXFLAGS is empty so don't check length here, just check it returns
    get_make_flag("SIDE_MODULE_CXXFLAGS")


def test_get_make_environment_vars():
    vars = get_make_environment_vars()
    assert "SIDE_MODULE_LDFLAGS" in vars
    assert "SIDE_MODULE_CFLAGS" in vars
    assert "SIDE_MODULE_CXXFLAGS" in vars
    assert "TOOLSDIR" in vars

import sys
from pathlib import Path

sys.path.append(str(Path(__file__).parents[2]))

from pyodide_build.common import (
    _parse_package_subset,
    get_make_flag,
    get_make_environment_vars,
)  # noqa


def test_parse_package_subset():
    assert _parse_package_subset(None) is None
    # micropip is always included
    assert _parse_package_subset("numpy,pandas") == {
        "pyparsing",
        "packaging",
        "micropip",
        "numpy",
        "pandas",
    }

    # duplicates are removed
    assert _parse_package_subset("numpy,numpy") == {
        "pyparsing",
        "packaging",
        "micropip",
        "numpy",
    }

    # no empty package name included, spaces are handled
    assert _parse_package_subset("x,  a, b, c   ,,, d,,") == {
        "pyparsing",
        "packaging",
        "micropip",
        "x",
        "a",
        "b",
        "c",
        "d",
    }


def test_get_make_flag():
    assert len(get_make_flag("SIDE_MODULE_LDFLAGS")) > 0
    assert len(get_make_flag("SIDE_MODULE_CFLAGS")) > 0
    # n.b. right now CXXFLAGS is empty so don't check length here, just check it returns
    get_make_flag("SIDE_MODULE_CXXFLAGS")


def test_get_make_environment_vars():
    vars = get_make_environment_vars()
    assert "SIDE_MODULE_LDFLAGS" in vars
    assert "SIDE_MODULE_CFLAGS" in vars
    assert "SIDE_MODULE_CXXFLAGS" in vars
    assert "TOOLSDIR" in vars
