chore(types): upgrade to TypeScript 2.8.1 (#2304)

This converts `externs.d.ts` to export a global namespace instead of a UMD global.

See: https://github.com/Microsoft/TypeScript/issues/22969

Fixes #2279.
This commit is contained in:
JoelEinbinder
2018-04-04 14:06:21 -07:00
committed by Andrey Lushnikov
parent 3b88d0d7c9
commit 2370618819
5 changed files with 50 additions and 40 deletions

View File

@@ -19,7 +19,11 @@ const ESTreeWalker = require('../../ESTreeWalker');
const Documentation = require('./Documentation');
class JSOutline {
constructor(text) {
/**
* @param {string} text
* @param {string} name
*/
constructor(text, name) {
this.classes = [];
/** @type {!Map<string, string>} */
this.inheritance = new Map();
@@ -27,11 +31,12 @@ class JSOutline {
this._eventsByClassName = new Map();
this._currentClassName = null;
this._currentClassMembers = [];
this._name = name;
this._text = text;
const ast = esprima.parseScript(this._text, {loc: true, range: true});
const walker = new ESTreeWalker(node => {
if (node.type === 'ClassDeclaration')
if (node.type === 'ClassDeclaration' || node.type === 'ClassExpression')
this._onClassDeclaration(node);
else if (node.type === 'MethodDefinition')
this._onMethodDefinition(node);
@@ -46,6 +51,8 @@ class JSOutline {
_onClassDeclaration(node) {
this._flushClassIfNeeded();
this._currentClassName = this._extractText(node.id);
if (!this._currentClassName)
this._currentClassName = this._name.substring(0, this._name.indexOf('.'));
const superClass = this._extractText(node.superClass);
if (superClass)
this.inheritance.set(this._currentClassName, superClass);
@@ -179,7 +186,7 @@ module.exports = async function(sources) {
const errors = [];
const inheritance = new Map();
for (const source of sources) {
const outline = new JSOutline(source.text());
const outline = new JSOutline(source.text(), source.name());
classes.push(...outline.classes);
errors.push(...outline.errors);
for (const entry of outline.inheritance)