Add support for declare export + fixes (#224)

* Add support for declare export

* Do not allow declare module inside declare module

* Reallow module exports outside module

* Add handling of `declare export default`

Add check for multiple module.export declarations

* Disallow export let/const/type

Refactor parsing object properties to share more code and add support
for getters and setters

* Rename tests

* Update test fixtures

* Optimize for performance

* disallow declare export interface outside of module

* Refactor code to be more readable and less lookahead

* Add comments

* Add test for export star as

* Test for number literal getter/setter

* Add more tests

* Fix tests

* Allow union types and correctly eat semi after type

* Use non computed keys

* Fix tests
This commit is contained in:
Daniel Tschinder 2017-04-21 14:41:59 +02:00 committed by GitHub
parent 28ccd05bab
commit d1a5220b89
117 changed files with 4857 additions and 708 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ build
coverage
lib
node_modules
npm-debug.log

View File

@ -810,7 +810,8 @@ pp.parseClassSuper = function (node) {
// Parses module export declaration.
pp.parseExport = function (node) {
this.next();
this.eat(tt._export);
// export * from '...'
if (this.match(tt.star)) {
const specifier = this.startNode();

View File

@ -105,7 +105,7 @@ pp.flowParseDeclareFunction = function (node) {
return this.finishNode(node, "DeclareFunction");
};
pp.flowParseDeclare = function (node) {
pp.flowParseDeclare = function (node, insideModule) {
if (this.match(tt._class)) {
return this.flowParseDeclareClass(node);
} else if (this.match(tt._function)) {
@ -116,12 +116,15 @@ pp.flowParseDeclare = function (node) {
if (this.lookahead().type === tt.dot) {
return this.flowParseDeclareModuleExports(node);
} else {
if (insideModule) this.unexpected(null, "`declare module` cannot be used inside another `declare module`");
return this.flowParseDeclareModule(node);
}
} else if (this.isContextual("type")) {
return this.flowParseDeclareTypeAlias(node);
} else if (this.isContextual("interface")) {
return this.flowParseDeclareInterface(node);
} else if (this.match(tt._export)) {
return this.flowParseDeclareExportDeclaration(node, insideModule);
} else {
this.unexpected();
}
@ -134,6 +137,17 @@ pp.flowParseDeclareVariable = function (node) {
return this.finishNode(node, "DeclareVariable");
};
function isEsModuleType(bodyElement) {
return bodyElement.type === "DeclareExportAllDeclaration" ||
(
bodyElement.type === "DeclareExportDeclaration" &&
(
!bodyElement.declaration ||
(bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration")
)
);
}
pp.flowParseDeclareModule = function (node) {
this.next();
@ -167,9 +181,94 @@ pp.flowParseDeclareModule = function (node) {
this.expect(tt.braceR);
this.finishNode(bodyNode, "BlockStatement");
let kind = null;
let hasModuleExport = false;
const errorMessage = "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module";
body.forEach((bodyElement) => {
if (isEsModuleType(bodyElement)) {
if (kind === "CommonJS") this.unexpected(bodyElement.start, errorMessage);
kind = "ES";
} else if (bodyElement.type === "DeclareModuleExports") {
if (hasModuleExport) this.unexpected(bodyElement.start, "Duplicate `declare module.exports` statement");
if (kind === "ES") this.unexpected(bodyElement.start, errorMessage);
kind = "CommonJS";
hasModuleExport = true;
}
});
node.kind = kind || "CommonJS";
return this.finishNode(node, "DeclareModule");
};
const exportSuggestions = {
const: "declare export var",
let: "declare export var",
type: "export type",
interface: "export interface",
};
pp.flowParseDeclareExportDeclaration = function (node, insideModule) {
this.expect(tt._export);
if (this.eat(tt._default)) {
if (this.match(tt._function) || this.match(tt._class)) {
// declare export default class ...
// declare export default function ...
node.declaration = this.flowParseDeclare(this.startNode());
} else {
// declare export default [type];
node.declaration = this.flowParseType();
this.semicolon();
}
node.default = true;
return this.finishNode(node, "DeclareExportDeclaration");
} else {
if (
this.match(tt._const) || this.match(tt._let) ||
(
(this.isContextual("type") || this.isContextual("interface")) &&
!insideModule
)
) {
const label = this.state.value;
const suggestion = exportSuggestions[label];
this.unexpected(this.state.start, `\`declare export ${label}\` is not supported. Use \`${suggestion}\` instead`);
}
if (
this.match(tt._var) || // declare export var ...
this.match(tt._function) || // declare export function ...
this.match(tt._class) // declare export class ...
) {
node.declaration = this.flowParseDeclare(this.startNode());
node.default = false;
return this.finishNode(node, "DeclareExportDeclaration");
} else if (
this.match(tt.star) || // declare export * from ''
this.match(tt.braceL) || // declare export {} ...
this.isContextual("interface") || // declare export interface ...
this.isContextual("type") // declare export type ...
) {
node = this.parseExport(node);
if (node.type === "ExportNamedDeclaration") {
// flow does not support the ExportNamedDeclaration
node.type = "ExportDeclaration";
node.default = false;
delete node.exportKind;
}
node.type = "Declare" + node.type;
return node;
}
}
this.unexpected();
};
pp.flowParseDeclareModuleExports = function (node) {
this.expectContextual("module");
this.expect(tt.dot);
@ -381,15 +480,6 @@ pp.flowParseObjectTypeMethodish = function (node) {
return this.finishNode(node, "FunctionTypeAnnotation");
};
pp.flowParseObjectTypeMethod = function (startPos, startLoc, isStatic, key) {
const node = this.startNodeAt(startPos, startLoc);
node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(startPos, startLoc));
node.static = isStatic;
node.key = key;
node.optional = false;
return this.finishNode(node, "ObjectTypeProperty");
};
pp.flowParseObjectTypeCallProperty = function (node, isStatic) {
const valueNode = this.startNode();
node.static = isStatic;
@ -402,9 +492,6 @@ pp.flowParseObjectType = function (allowStatic, allowExact, allowSpread) {
this.state.inType = true;
const nodeStart = this.startNode();
let node;
let propertyKey;
let isStatic = false;
nodeStart.callProperties = [];
nodeStart.properties = [];
@ -425,10 +512,8 @@ pp.flowParseObjectType = function (allowStatic, allowExact, allowSpread) {
nodeStart.exact = exact;
while (!this.match(endDelim)) {
let optional = false;
const startPos = this.state.start;
const startLoc = this.state.startLoc;
node = this.startNode();
let isStatic = false;
const node = this.startNode();
if (allowStatic && this.isContextual("static") && this.lookahead().type !== tt.colon) {
this.next();
isStatic = true;
@ -444,44 +529,24 @@ pp.flowParseObjectType = function (allowStatic, allowExact, allowSpread) {
}
nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
} else {
if (this.match(tt.ellipsis)) {
if (!allowSpread) {
this.unexpected(
null,
"Spread operator cannot appear in class or interface definitions"
);
}
if (variance) {
this.unexpected(variance.start, "Spread properties cannot have variance");
}
this.expect(tt.ellipsis);
node.argument = this.flowParseType();
nodeStart.properties.push(this.finishNode(node, "ObjectTypeSpreadProperty"));
} else {
propertyKey = this.flowParseObjectPropertyKey();
if (this.isRelational("<") || this.match(tt.parenL)) {
// This is a method property
if (variance) {
this.unexpected(variance.start);
}
nodeStart.properties.push(this.flowParseObjectTypeMethod(startPos, startLoc, isStatic, propertyKey));
} else {
if (this.eat(tt.question)) {
optional = true;
}
node.key = propertyKey;
node.value = this.flowParseTypeInitialiser();
node.optional = optional;
node.static = isStatic;
node.variance = variance;
nodeStart.properties.push(this.finishNode(node, "ObjectTypeProperty"));
let kind = "init";
if (this.isContextual("get") || this.isContextual("set")) {
const lookahead = this.lookahead();
if (
lookahead.type === tt.name ||
lookahead.type === tt.string ||
lookahead.type === tt.num
) {
kind = this.state.value;
this.next();
}
}
nodeStart.properties.push(this.flowParseObjectTypeProperty(node, isStatic, variance, kind, allowSpread));
}
this.flowObjectTypeSemicolon();
isStatic = false;
}
this.expect(endDelim);
@ -493,6 +558,65 @@ pp.flowParseObjectType = function (allowStatic, allowExact, allowSpread) {
return out;
};
pp.flowParseObjectTypeProperty = function (node, isStatic, variance, kind, allowSpread) {
if (this.match(tt.ellipsis)) {
if (!allowSpread) {
this.unexpected(
null,
"Spread operator cannot appear in class or interface definitions"
);
}
if (variance) {
this.unexpected(variance.start, "Spread properties cannot have variance");
}
this.expect(tt.ellipsis);
node.argument = this.flowParseType();
return this.finishNode(node, "ObjectTypeSpreadProperty");
} else {
node.key = this.flowParseObjectPropertyKey();
node.static = isStatic;
node.kind = kind;
let optional = false;
if (this.isRelational("<") || this.match(tt.parenL)) {
// This is a method property
if (variance) {
this.unexpected(variance.start);
}
node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
if (kind === "get" || kind === "set") this.flowCheckGetterSetterParamCount(node);
} else {
if (kind !== "init") this.unexpected();
if (this.eat(tt.question)) {
optional = true;
}
node.value = this.flowParseTypeInitialiser();
node.variance = variance;
}
node.optional = optional;
return this.finishNode(node, "ObjectTypeProperty");
}
};
// This is similar to checkGetterSetterParamCount, but as
// babylon uses non estree properties we cannot reuse it here
pp.flowCheckGetterSetterParamCount = function (property) {
const paramCount = property.kind === "get" ? 0 : 1;
if (property.value.params.length !== paramCount) {
const start = property.start;
if (property.kind === "get") {
this.raise(start, "getter should have no params");
} else {
this.raise(start, "setter should have exactly one param");
}
}
};
pp.flowObjectTypeSemicolon = function () {
if (!this.eat(tt.semi) && !this.eat(tt.comma) &&
!this.match(tt.braceR) && !this.match(tt.braceBarR)) {
@ -898,7 +1022,7 @@ export default (superClass) => class extends superClass {
parseExpressionStatement(node, expr) {
if (expr.type === "Identifier") {
if (expr.name === "declare") {
if (this.match(tt._class) || this.match(tt.name) || this.match(tt._function) || this.match(tt._var)) {
if (this.match(tt._class) || this.match(tt.name) || this.match(tt._function) || this.match(tt._var) || this.match(tt._export)) {
return this.flowParseDeclare(node);
}
} else if (this.match(tt.name)) {

View File

@ -282,6 +282,8 @@
},
"name": "y"
},
"static": false,
"kind": "init",
"value": {
"type": "StringTypeAnnotation",
"start": 25,
@ -297,9 +299,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -0,0 +1,8 @@
declare class B {
get a(): number;
set b(a: number): void;
get "c"(): number;
set "d"(a: number): void;
get 1(): number;
set 2(a: number): void;
}

View File

@ -0,0 +1,656 @@
{
"type": "File",
"start": 0,
"end": 158,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 8,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 158,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 8,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareClass",
"start": 0,
"end": 158,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 8,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "B"
},
"name": "B"
},
"typeParameters": null,
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 16,
"end": 158,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 8,
"column": 1
}
},
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
"start": 20,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 17
}
},
"key": {
"type": "Identifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "a"
},
"name": "a"
},
"static": false,
"kind": "get",
"value": {
"type": "FunctionTypeAnnotation",
"start": 20,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 17
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "NumberTypeAnnotation",
"start": 29,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 17
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 39,
"end": 61,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 24
}
},
"key": {
"type": "Identifier",
"start": 43,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 7
},
"identifierName": "b"
},
"name": "b"
},
"static": false,
"kind": "set",
"value": {
"type": "FunctionTypeAnnotation",
"start": 39,
"end": 61,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 24
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 45,
"end": 54,
"loc": {
"start": {
"line": 3,
"column": 8
},
"end": {
"line": 3,
"column": 17
}
},
"name": {
"type": "Identifier",
"start": 45,
"end": 46,
"loc": {
"start": {
"line": 3,
"column": 8
},
"end": {
"line": 3,
"column": 9
},
"identifierName": "a"
},
"name": "a"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 48,
"end": 54,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 17
}
}
}
}
],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 57,
"end": 61,
"loc": {
"start": {
"line": 3,
"column": 20
},
"end": {
"line": 3,
"column": 24
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 65,
"end": 82,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 19
}
},
"key": {
"type": "StringLiteral",
"start": 69,
"end": 72,
"loc": {
"start": {
"line": 4,
"column": 6
},
"end": {
"line": 4,
"column": 9
}
},
"extra": {
"rawValue": "c",
"raw": "\"c\""
},
"value": "c"
},
"static": false,
"kind": "get",
"value": {
"type": "FunctionTypeAnnotation",
"start": 65,
"end": 82,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 19
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "NumberTypeAnnotation",
"start": 76,
"end": 82,
"loc": {
"start": {
"line": 4,
"column": 13
},
"end": {
"line": 4,
"column": 19
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 86,
"end": 110,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 26
}
},
"key": {
"type": "StringLiteral",
"start": 90,
"end": 93,
"loc": {
"start": {
"line": 5,
"column": 6
},
"end": {
"line": 5,
"column": 9
}
},
"extra": {
"rawValue": "d",
"raw": "\"d\""
},
"value": "d"
},
"static": false,
"kind": "set",
"value": {
"type": "FunctionTypeAnnotation",
"start": 86,
"end": 110,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 26
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 94,
"end": 103,
"loc": {
"start": {
"line": 5,
"column": 10
},
"end": {
"line": 5,
"column": 19
}
},
"name": {
"type": "Identifier",
"start": 94,
"end": 95,
"loc": {
"start": {
"line": 5,
"column": 10
},
"end": {
"line": 5,
"column": 11
},
"identifierName": "a"
},
"name": "a"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 97,
"end": 103,
"loc": {
"start": {
"line": 5,
"column": 13
},
"end": {
"line": 5,
"column": 19
}
}
}
}
],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 106,
"end": 110,
"loc": {
"start": {
"line": 5,
"column": 22
},
"end": {
"line": 5,
"column": 26
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 114,
"end": 129,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 6,
"column": 17
}
},
"key": {
"type": "NumericLiteral",
"start": 118,
"end": 119,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 7
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
"static": false,
"kind": "get",
"value": {
"type": "FunctionTypeAnnotation",
"start": 114,
"end": 129,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 6,
"column": 17
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "NumberTypeAnnotation",
"start": 123,
"end": 129,
"loc": {
"start": {
"line": 6,
"column": 11
},
"end": {
"line": 6,
"column": 17
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 133,
"end": 155,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 7,
"column": 24
}
},
"key": {
"type": "NumericLiteral",
"start": 137,
"end": 138,
"loc": {
"start": {
"line": 7,
"column": 6
},
"end": {
"line": 7,
"column": 7
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
},
"static": false,
"kind": "set",
"value": {
"type": "FunctionTypeAnnotation",
"start": 133,
"end": 155,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 7,
"column": 24
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 139,
"end": 148,
"loc": {
"start": {
"line": 7,
"column": 8
},
"end": {
"line": 7,
"column": 17
}
},
"name": {
"type": "Identifier",
"start": 139,
"end": 140,
"loc": {
"start": {
"line": 7,
"column": 8
},
"end": {
"line": 7,
"column": 9
},
"identifierName": "a"
},
"name": "a"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 142,
"end": 148,
"loc": {
"start": {
"line": 7,
"column": 11
},
"end": {
"line": 7,
"column": 17
}
}
}
}
],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 151,
"end": 155,
"loc": {
"start": {
"line": 7,
"column": 20
},
"end": {
"line": 7,
"column": 24
}
}
}
},
"optional": false
}
],
"indexers": [],
"exact": false
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
declare class B {
get a: number;
}

View File

@ -0,0 +1,3 @@
{
"throws": "Unexpected token (2:7)"
}

View File

@ -0,0 +1,33 @@
{
"type": "File",
"start": 0,
"end": 0,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 0,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 0
}
},
"sourceType": "module",
"body": [],
"directives": []
}
}

View File

@ -109,6 +109,8 @@
},
"name": "static"
},
"static": false,
"kind": "init",
"value": {
"type": "GenericTypeAnnotation",
"start": 28,
@ -142,9 +144,8 @@
"name": "T"
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -0,0 +1 @@
declare module "foo" { declare export class Foo { meth(p1: number): void; } }

View File

@ -0,0 +1,275 @@
{
"type": "File",
"start": 0,
"end": 77,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 77
}
},
"program": {
"type": "Program",
"start": 0,
"end": 77,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 77
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 77,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 77
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 77,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 77
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 75,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 75
}
},
"declaration": {
"type": "DeclareClass",
"start": 38,
"end": 75,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 75
}
},
"id": {
"type": "Identifier",
"start": 44,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 44
},
"end": {
"line": 1,
"column": 47
},
"identifierName": "Foo"
},
"name": "Foo"
},
"typeParameters": null,
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 48,
"end": 75,
"loc": {
"start": {
"line": 1,
"column": 48
},
"end": {
"line": 1,
"column": 75
}
},
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
"start": 50,
"end": 72,
"loc": {
"start": {
"line": 1,
"column": 50
},
"end": {
"line": 1,
"column": 72
}
},
"key": {
"type": "Identifier",
"start": 50,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 50
},
"end": {
"line": 1,
"column": 54
},
"identifierName": "meth"
},
"name": "meth"
},
"static": false,
"kind": "init",
"value": {
"type": "FunctionTypeAnnotation",
"start": 50,
"end": 72,
"loc": {
"start": {
"line": 1,
"column": 50
},
"end": {
"line": 1,
"column": 72
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 55,
"end": 65,
"loc": {
"start": {
"line": 1,
"column": 55
},
"end": {
"line": 1,
"column": 65
}
},
"name": {
"type": "Identifier",
"start": 55,
"end": 57,
"loc": {
"start": {
"line": 1,
"column": 55
},
"end": {
"line": 1,
"column": 57
},
"identifierName": "p1"
},
"name": "p1"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 59,
"end": 65,
"loc": {
"start": {
"line": 1,
"column": 59
},
"end": {
"line": 1,
"column": 65
}
}
}
}
],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 68,
"end": 72,
"loc": {
"start": {
"line": 1,
"column": 68
},
"end": {
"line": 1,
"column": 72
}
}
}
},
"optional": false
}
],
"indexers": [],
"exact": false
}
},
"default": false
}
]
},
"kind": "ES"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare export default (a:number) => number

View File

@ -0,0 +1,132 @@
{
"type": "File",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 43
}
},
"program": {
"type": "Program",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 43
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareExportDeclaration",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 43
}
},
"declaration": {
"type": "FunctionTypeAnnotation",
"start": 23,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 43
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 24,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 32
}
},
"name": {
"type": "Identifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 25
},
"identifierName": "a"
},
"name": "a"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 26,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 32
}
}
}
}
],
"rest": null,
"returnType": {
"type": "NumberTypeAnnotation",
"start": 37,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 37
},
"end": {
"line": 1,
"column": 43
}
}
},
"typeParameters": null
},
"default": true
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare export default class A {};

View File

@ -0,0 +1,119 @@
{
"type": "File",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"program": {
"type": "Program",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareExportDeclaration",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"declaration": {
"type": "DeclareClass",
"start": 23,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 33
}
},
"id": {
"type": "Identifier",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 30
},
"identifierName": "A"
},
"name": "A"
},
"typeParameters": null,
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 31,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 33
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"exact": false
}
},
"default": true
},
{
"type": "EmptyStatement",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 34
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare export default function bar(p1: number): string;

View File

@ -0,0 +1,180 @@
{
"type": "File",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"program": {
"type": "Program",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareExportDeclaration",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"declaration": {
"type": "DeclareFunction",
"start": 23,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 56
}
},
"id": {
"type": "Identifier",
"start": 32,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 32
},
"end": {
"line": 1,
"column": 55
},
"identifierName": "bar"
},
"name": "bar",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 35,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 55
}
},
"typeAnnotation": {
"type": "FunctionTypeAnnotation",
"start": 35,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 55
}
},
"typeParameters": null,
"params": [
{
"type": "FunctionTypeParam",
"start": 36,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 36
},
"end": {
"line": 1,
"column": 46
}
},
"name": {
"type": "Identifier",
"start": 36,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 36
},
"end": {
"line": 1,
"column": 38
},
"identifierName": "p1"
},
"name": "p1"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 40,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 40
},
"end": {
"line": 1,
"column": 46
}
}
}
}
],
"rest": null,
"returnType": {
"type": "StringTypeAnnotation",
"start": 49,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 49
},
"end": {
"line": 1,
"column": 55
}
}
}
}
}
},
"predicate": null
},
"default": true
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export default number|string; }

View File

@ -0,0 +1,150 @@
{
"type": "File",
"start": 0,
"end": 62,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 62
}
},
"program": {
"type": "Program",
"start": 0,
"end": 62,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 62
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 62,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 62
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 62,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 62
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 60
}
},
"declaration": {
"type": "UnionTypeAnnotation",
"start": 46,
"end": 59,
"loc": {
"start": {
"line": 1,
"column": 46
},
"end": {
"line": 1,
"column": 59
}
},
"types": [
{
"type": "NumberTypeAnnotation",
"start": 46,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 46
},
"end": {
"line": 1,
"column": 52
}
}
},
{
"type": "StringTypeAnnotation",
"start": 53,
"end": 59,
"loc": {
"start": {
"line": 1,
"column": 53
},
"end": {
"line": 1,
"column": 59
}
}
}
]
},
"default": true
}
]
},
"kind": "ES"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export {a,} from "bar"; }

View File

@ -0,0 +1,175 @@
{
"type": "File",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"program": {
"type": "Program",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 56
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 54
}
},
"declaration": null,
"specifiers": [
{
"type": "ExportSpecifier",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 40
}
},
"local": {
"type": "Identifier",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 40
},
"identifierName": "a"
},
"name": "a"
},
"exported": {
"type": "Identifier",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 40
},
"identifierName": "a"
},
"name": "a"
}
}
],
"source": {
"type": "StringLiteral",
"start": 48,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 48
},
"end": {
"line": 1,
"column": 53
}
},
"extra": {
"rawValue": "bar",
"raw": "\"bar\""
},
"value": "bar"
},
"default": false
}
]
},
"kind": "ES"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export function bar(p1: number): string; }

View File

@ -0,0 +1,233 @@
{
"type": "File",
"start": 0,
"end": 73,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 73
}
},
"program": {
"type": "Program",
"start": 0,
"end": 73,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 73
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 73,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 73
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 73,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 73
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 71,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 71
}
},
"declaration": {
"type": "DeclareFunction",
"start": 38,
"end": 71,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 71
}
},
"id": {
"type": "Identifier",
"start": 47,
"end": 70,
"loc": {
"start": {
"line": 1,
"column": 47
},
"end": {
"line": 1,
"column": 70
},
"identifierName": "bar"
},
"name": "bar",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 50,
"end": 70,
"loc": {
"start": {
"line": 1,
"column": 50
},
"end": {
"line": 1,
"column": 70
}
},
"typeAnnotation": {
"type": "FunctionTypeAnnotation",
"start": 50,
"end": 70,
"loc": {
"start": {
"line": 1,
"column": 50
},
"end": {
"line": 1,
"column": 70
}
},
"typeParameters": null,
"params": [
{
"type": "FunctionTypeParam",
"start": 51,
"end": 61,
"loc": {
"start": {
"line": 1,
"column": 51
},
"end": {
"line": 1,
"column": 61
}
},
"name": {
"type": "Identifier",
"start": 51,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 51
},
"end": {
"line": 1,
"column": 53
},
"identifierName": "p1"
},
"name": "p1"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 55,
"end": 61,
"loc": {
"start": {
"line": 1,
"column": 55
},
"end": {
"line": 1,
"column": 61
}
}
}
}
],
"rest": null,
"returnType": {
"type": "StringTypeAnnotation",
"start": 64,
"end": 70,
"loc": {
"start": {
"line": 1,
"column": 64
},
"end": {
"line": 1,
"column": 70
}
}
}
}
}
},
"predicate": null
},
"default": false
}
]
},
"kind": "ES"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export interface bar {} declare export var baz: number; }

View File

@ -0,0 +1,237 @@
{
"type": "File",
"start": 0,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 88
}
},
"program": {
"type": "Program",
"start": 0,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 88
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 88
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 88
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 54
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "InterfaceDeclaration",
"start": 38,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 54
}
},
"id": {
"type": "Identifier",
"start": 48,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 48
},
"end": {
"line": 1,
"column": 51
},
"identifierName": "bar"
},
"name": "bar"
},
"typeParameters": null,
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 52,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 52
},
"end": {
"line": 1,
"column": 54
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"exact": false
}
},
"default": false
},
{
"type": "DeclareExportDeclaration",
"start": 55,
"end": 86,
"loc": {
"start": {
"line": 1,
"column": 55
},
"end": {
"line": 1,
"column": 86
}
},
"declaration": {
"type": "DeclareVariable",
"start": 70,
"end": 86,
"loc": {
"start": {
"line": 1,
"column": 70
},
"end": {
"line": 1,
"column": 86
}
},
"id": {
"type": "Identifier",
"start": 74,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 74
},
"end": {
"line": 1,
"column": 85
},
"identifierName": "baz"
},
"name": "baz",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 77,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 77
},
"end": {
"line": 1,
"column": 85
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 79,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 79
},
"end": {
"line": 1,
"column": 85
}
}
}
}
}
},
"default": false
}
]
},
"kind": "ES"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export interface bar {} declare module.exports: number; }

View File

@ -0,0 +1,204 @@
{
"type": "File",
"start": 0,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 88
}
},
"program": {
"type": "Program",
"start": 0,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 88
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 88
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 88
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 54
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "InterfaceDeclaration",
"start": 38,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 54
}
},
"id": {
"type": "Identifier",
"start": 48,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 48
},
"end": {
"line": 1,
"column": 51
},
"identifierName": "bar"
},
"name": "bar"
},
"typeParameters": null,
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 52,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 52
},
"end": {
"line": 1,
"column": 54
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"exact": false
}
},
"default": false
},
{
"type": "DeclareModuleExports",
"start": 55,
"end": 86,
"loc": {
"start": {
"line": 1,
"column": 55
},
"end": {
"line": 1,
"column": 86
}
},
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 77,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 77
},
"end": {
"line": 1,
"column": 85
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 79,
"end": 85,
"loc": {
"start": {
"line": 1,
"column": 79
},
"end": {
"line": 1,
"column": 85
}
}
}
}
}
]
},
"kind": "CommonJS"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export interface bar {} }

View File

@ -0,0 +1,159 @@
{
"type": "File",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"program": {
"type": "Program",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 56
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 54
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "InterfaceDeclaration",
"start": 38,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 54
}
},
"id": {
"type": "Identifier",
"start": 48,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 48
},
"end": {
"line": 1,
"column": 51
},
"identifierName": "bar"
},
"name": "bar"
},
"typeParameters": null,
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 52,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 52
},
"end": {
"line": 1,
"column": 54
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"exact": false
}
},
"default": false
}
]
},
"kind": "CommonJS"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export {a,}; }

View File

@ -0,0 +1,156 @@
{
"type": "File",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 45
}
},
"program": {
"type": "Program",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 45
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 45
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 45
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 43
}
},
"declaration": null,
"specifiers": [
{
"type": "ExportSpecifier",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 40
}
},
"local": {
"type": "Identifier",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 40
},
"identifierName": "a"
},
"name": "a"
},
"exported": {
"type": "Identifier",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 40
},
"identifierName": "a"
},
"name": "a"
}
}
],
"source": null,
"default": false
}
]
},
"kind": "ES"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare export * as test from ''

View File

@ -0,0 +1,104 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareExportDeclaration",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"specifiers": [
{
"type": "ExportNamespaceSpecifier",
"start": 15,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 24
}
},
"exported": {
"type": "Identifier",
"start": 20,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 24
},
"identifierName": "test"
},
"name": "test"
}
}
],
"source": {
"type": "StringLiteral",
"start": 30,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 30
},
"end": {
"line": 1,
"column": 32
}
},
"extra": {
"rawValue": "",
"raw": "''"
},
"value": ""
},
"default": false
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["exportExtensions"]
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export * from "bar"; }

View File

@ -0,0 +1,122 @@
{
"type": "File",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 53
}
},
"program": {
"type": "Program",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 53
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 53
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 53
}
},
"body": [
{
"type": "DeclareExportAllDeclaration",
"start": 23,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 51
}
},
"source": {
"type": "StringLiteral",
"start": 45,
"end": 50,
"loc": {
"start": {
"line": 1,
"column": 45
},
"end": {
"line": 1,
"column": 50
}
},
"extra": {
"rawValue": "bar",
"raw": "\"bar\""
},
"value": "bar"
}
}
]
},
"kind": "ES"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export type bar = number; declare export var baz: number; }

View File

@ -0,0 +1,231 @@
{
"type": "File",
"start": 0,
"end": 90,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 90
}
},
"program": {
"type": "Program",
"start": 0,
"end": 90,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 90
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 90,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 90
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 90,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 90
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 56
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "TypeAlias",
"start": 38,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 56
}
},
"id": {
"type": "Identifier",
"start": 43,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 43
},
"end": {
"line": 1,
"column": 46
},
"identifierName": "bar"
},
"name": "bar"
},
"typeParameters": null,
"right": {
"type": "NumberTypeAnnotation",
"start": 49,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 49
},
"end": {
"line": 1,
"column": 55
}
}
}
},
"default": false
},
{
"type": "DeclareExportDeclaration",
"start": 57,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 57
},
"end": {
"line": 1,
"column": 88
}
},
"declaration": {
"type": "DeclareVariable",
"start": 72,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 72
},
"end": {
"line": 1,
"column": 88
}
},
"id": {
"type": "Identifier",
"start": 76,
"end": 87,
"loc": {
"start": {
"line": 1,
"column": 76
},
"end": {
"line": 1,
"column": 87
},
"identifierName": "baz"
},
"name": "baz",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 79,
"end": 87,
"loc": {
"start": {
"line": 1,
"column": 79
},
"end": {
"line": 1,
"column": 87
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 81,
"end": 87,
"loc": {
"start": {
"line": 1,
"column": 81
},
"end": {
"line": 1,
"column": 87
}
}
}
}
}
},
"default": false
}
]
},
"kind": "ES"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export type bar = number; declare module.exports: number; }

View File

@ -0,0 +1,198 @@
{
"type": "File",
"start": 0,
"end": 90,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 90
}
},
"program": {
"type": "Program",
"start": 0,
"end": 90,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 90
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 90,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 90
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 90,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 90
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 56
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "TypeAlias",
"start": 38,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 56
}
},
"id": {
"type": "Identifier",
"start": 43,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 43
},
"end": {
"line": 1,
"column": 46
},
"identifierName": "bar"
},
"name": "bar"
},
"typeParameters": null,
"right": {
"type": "NumberTypeAnnotation",
"start": 49,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 49
},
"end": {
"line": 1,
"column": 55
}
}
}
},
"default": false
},
{
"type": "DeclareModuleExports",
"start": 57,
"end": 88,
"loc": {
"start": {
"line": 1,
"column": 57
},
"end": {
"line": 1,
"column": 88
}
},
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 79,
"end": 87,
"loc": {
"start": {
"line": 1,
"column": 79
},
"end": {
"line": 1,
"column": 87
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 81,
"end": 87,
"loc": {
"start": {
"line": 1,
"column": 81
},
"end": {
"line": 1,
"column": 87
}
}
}
}
}
]
},
"kind": "CommonJS"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export type bar = number; }

View File

@ -0,0 +1,153 @@
{
"type": "File",
"start": 0,
"end": 58,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 58
}
},
"program": {
"type": "Program",
"start": 0,
"end": 58,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 58
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 58,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 58
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 58,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 58
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 56
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "TypeAlias",
"start": 38,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 56
}
},
"id": {
"type": "Identifier",
"start": 43,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 43
},
"end": {
"line": 1,
"column": 46
},
"identifierName": "bar"
},
"name": "bar"
},
"typeParameters": null,
"right": {
"type": "NumberTypeAnnotation",
"start": 49,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 49
},
"end": {
"line": 1,
"column": 55
}
}
}
},
"default": false
}
]
},
"kind": "CommonJS"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export var a: number; }

View File

@ -0,0 +1,165 @@
{
"type": "File",
"start": 0,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 54
}
},
"program": {
"type": "Program",
"start": 0,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 54
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 54
}
},
"id": {
"type": "StringLiteral",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
},
"body": {
"type": "BlockStatement",
"start": 21,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 54
}
},
"body": [
{
"type": "DeclareExportDeclaration",
"start": 23,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 52
}
},
"declaration": {
"type": "DeclareVariable",
"start": 38,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 38
},
"end": {
"line": 1,
"column": 52
}
},
"id": {
"type": "Identifier",
"start": 42,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 42
},
"end": {
"line": 1,
"column": 51
},
"identifierName": "a"
},
"name": "a",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 43,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 43
},
"end": {
"line": 1,
"column": 51
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 45,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 45
},
"end": {
"line": 1,
"column": 51
}
}
}
}
}
},
"default": false
}
]
},
"kind": "ES"
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare export type foo = number;

View File

@ -0,0 +1,3 @@
{
"throws": "`declare export type` is not supported. Use `export type` instead (1:15)"
}

View File

@ -0,0 +1 @@
declare export (a:number) => number

View File

@ -0,0 +1,3 @@
{
"throws": "Unexpected token (1:15)"
}

View File

@ -0,0 +1 @@
declare export const foo: number

View File

@ -0,0 +1,3 @@
{
"throws": "`declare export const` is not supported. Use `declare export var` instead (1:15)"
}

View File

@ -0,0 +1 @@
declare export default function (p1: number): string;

View File

@ -0,0 +1,3 @@
{
"throws": "Unexpected token (1:32)"
}

View File

@ -0,0 +1 @@
declare export default var a: number

View File

@ -0,0 +1,3 @@
{
"throws": "Unexpected token (1:23)"
}

View File

@ -0,0 +1 @@
declare export interface bar {}

View File

@ -0,0 +1,3 @@
{
"throws": "`declare export interface` is not supported. Use `export interface` instead (1:15)"
}

View File

@ -0,0 +1 @@
declare export let foo: number

View File

@ -0,0 +1,3 @@
{
"throws": "`declare export let` is not supported. Use `declare export var` instead (1:15)"
}

View File

@ -74,7 +74,8 @@
}
},
"body": []
}
},
"kind": "CommonJS"
}
],
"directives": []

View File

@ -0,0 +1 @@
declare module.exports: { foo(): number; }

View File

@ -0,0 +1,152 @@
{
"type": "File",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 42
}
},
"program": {
"type": "Program",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 42
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareModuleExports",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 42
}
},
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 22,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 42
}
},
"typeAnnotation": {
"type": "ObjectTypeAnnotation",
"start": 24,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 42
}
},
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
"start": 26,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 39
}
},
"key": {
"type": "Identifier",
"start": 26,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 29
},
"identifierName": "foo"
},
"name": "foo"
},
"static": false,
"kind": "init",
"value": {
"type": "FunctionTypeAnnotation",
"start": 26,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 39
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "NumberTypeAnnotation",
"start": 33,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 39
}
}
}
},
"optional": false
}
],
"indexers": [],
"exact": false
}
}
}
],
"directives": []
}
}

View File

@ -77,7 +77,8 @@
}
},
"body": []
}
},
"kind": "CommonJS"
}
],
"directives": []

View File

@ -137,7 +137,8 @@
}
}
]
}
},
"kind": "CommonJS"
}
],
"directives": []

View File

@ -156,7 +156,8 @@
"predicate": null
}
]
}
},
"kind": "CommonJS"
}
],
"directives": []

View File

@ -138,6 +138,25 @@
"column": 50
}
},
"key": {
"type": "Identifier",
"start": 37,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 37
},
"end": {
"line": 1,
"column": 40
},
"identifierName": "foo"
},
"name": "foo"
},
"static": false,
"kind": "init",
"value": {
"type": "FunctionTypeAnnotation",
"start": 37,
@ -171,24 +190,6 @@
}
}
},
"static": false,
"key": {
"type": "Identifier",
"start": 37,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 37
},
"end": {
"line": 1,
"column": 40
},
"identifierName": "foo"
},
"name": "foo"
},
"optional": false
}
],
@ -197,7 +198,8 @@
}
}
]
}
},
"kind": "CommonJS"
}
],
"directives": []

View File

@ -132,6 +132,25 @@
"column": 58
}
},
"key": {
"type": "Identifier",
"start": 45,
"end": 48,
"loc": {
"start": {
"line": 1,
"column": 45
},
"end": {
"line": 1,
"column": 48
},
"identifierName": "foo"
},
"name": "foo"
},
"static": false,
"kind": "init",
"value": {
"type": "FunctionTypeAnnotation",
"start": 45,
@ -165,24 +184,6 @@
}
}
},
"static": false,
"key": {
"type": "Identifier",
"start": 45,
"end": 48,
"loc": {
"start": {
"line": 1,
"column": 45
},
"end": {
"line": 1,
"column": 48
},
"identifierName": "foo"
},
"name": "foo"
},
"optional": false
}
],
@ -192,7 +193,8 @@
}
}
]
}
},
"kind": "CommonJS"
}
],
"directives": []

View File

@ -120,7 +120,8 @@
}
}
]
}
},
"kind": "CommonJS"
}
],
"directives": []

View File

@ -148,7 +148,8 @@
}
}
]
}
},
"kind": "CommonJS"
}
],
"directives": []

View File

@ -0,0 +1 @@
declare module "foo" { declare module.exports: number; declare export var a: number; }

View File

@ -0,0 +1,3 @@
{
"throws": "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module (1:55)"
}

View File

@ -0,0 +1 @@
declare module "foo" { declare export var a: number; declare module.exports: number; }

View File

@ -0,0 +1,3 @@
{
"throws": "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module (1:53)"
}

View File

@ -0,0 +1 @@
declare module A { declare module B {} }

View File

@ -0,0 +1,3 @@
{
"throws": "`declare module` cannot be used inside another `declare module` (1:27)"
}

View File

@ -0,0 +1 @@
declare module "foo" { declare module.exports: string; declare module.exports: number; }

View File

@ -0,0 +1,3 @@
{
"throws": "Duplicate `declare module.exports` statement (1:55)"
}

View File

@ -92,6 +92,25 @@
"column": 38
}
},
"key": {
"type": "Identifier",
"start": 25,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 28
},
"identifierName": "foo"
},
"name": "foo"
},
"static": true,
"kind": "init",
"value": {
"type": "FunctionTypeAnnotation",
"start": 18,
@ -125,24 +144,6 @@
}
}
},
"static": true,
"key": {
"type": "Identifier",
"start": 25,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 28
},
"identifierName": "foo"
},
"name": "foo"
},
"optional": false
},
{
@ -176,6 +177,8 @@
},
"name": "x"
},
"static": true,
"kind": "init",
"value": {
"type": "StringTypeAnnotation",
"start": 51,
@ -191,9 +194,8 @@
}
}
},
"optional": false,
"static": true,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -109,6 +109,8 @@
},
"name": "foo"
},
"static": false,
"kind": "init",
"value": {
"type": "StringTypeAnnotation",
"start": 27,
@ -124,9 +126,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -247,6 +248,8 @@
},
"name": "foo"
},
"static": false,
"kind": "init",
"value": {
"type": "GenericTypeAnnotation",
"start": 66,
@ -280,9 +283,8 @@
"name": "T"
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -109,6 +109,8 @@
},
"name": "a"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 22,
@ -124,9 +126,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeProperty",
@ -159,6 +160,8 @@
},
"name": "b"
},
"static": true,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 41,
@ -174,9 +177,8 @@
}
}
},
"optional": false,
"static": true,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeProperty",
@ -209,6 +211,8 @@
},
"name": "c"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 53,
@ -224,9 +228,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -92,6 +92,25 @@
"column": 71
}
},
"key": {
"type": "Identifier",
"start": 29,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 39
},
"identifierName": "didAnimate"
},
"name": "didAnimate"
},
"static": false,
"kind": "init",
"value": {
"type": "FunctionTypeAnnotation",
"start": 29,
@ -240,24 +259,6 @@
}
}
},
"static": false,
"key": {
"type": "Identifier",
"start": 29,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 39
},
"identifierName": "didAnimate"
},
"name": "didAnimate"
},
"optional": false
}
],

View File

@ -225,6 +225,8 @@
},
"name": "x"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 37,
@ -240,9 +242,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -0,0 +1 @@
declare 1;

View File

@ -0,0 +1,3 @@
{
"throws": "Unexpected token, expected ; (1:8)"
}

View File

@ -159,6 +159,8 @@
},
"name": "x"
},
"static": false,
"kind": "init",
"value": {
"type": "BooleanTypeAnnotation",
"start": 22,
@ -174,9 +176,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeProperty",
@ -209,6 +210,8 @@
},
"name": "y"
},
"static": true,
"kind": "init",
"value": {
"type": "BooleanTypeAnnotation",
"start": 62,
@ -224,9 +227,8 @@
}
}
},
"optional": false,
"static": true,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -109,6 +109,8 @@
},
"name": "foo"
},
"static": false,
"kind": "init",
"value": {
"type": "FunctionTypeAnnotation",
"start": 19,
@ -142,9 +144,8 @@
},
"typeParameters": null
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -109,6 +109,8 @@
},
"name": "length"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 56,
@ -124,9 +126,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [

View File

@ -0,0 +1,3 @@
type B = {
get a(foo:number): number;
}

View File

@ -0,0 +1,3 @@
{
"throws": "getter should have no params (2:2)"
}

View File

@ -0,0 +1,3 @@
type B = {
set a(): void;
}

View File

@ -0,0 +1,3 @@
{
"throws": "setter should have exactly one param (2:2)"
}

View File

@ -122,6 +122,8 @@
},
"name": "type"
},
"static": false,
"kind": "init",
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 23,
@ -142,9 +144,8 @@
},
"value": "A"
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -197,6 +198,8 @@
},
"name": "type"
},
"static": false,
"kind": "init",
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 38,
@ -217,9 +220,8 @@
},
"value": "B"
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -521,6 +523,8 @@
},
"name": "x"
},
"static": false,
"kind": "init",
"value": {
"type": "UnionTypeAnnotation",
"start": 147,
@ -583,6 +587,8 @@
},
"name": "type"
},
"static": false,
"kind": "init",
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 156,
@ -603,9 +609,8 @@
},
"value": "A"
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -658,6 +663,8 @@
},
"name": "type"
},
"static": false,
"kind": "init",
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 174,
@ -678,9 +685,8 @@
},
"value": "B"
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -688,9 +694,8 @@
}
]
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -776,6 +781,8 @@
},
"name": "x"
},
"static": false,
"kind": "init",
"value": {
"type": "IntersectionTypeAnnotation",
"start": 212,
@ -838,6 +845,8 @@
},
"name": "type"
},
"static": false,
"kind": "init",
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 221,
@ -858,9 +867,8 @@
},
"value": "A"
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -913,6 +921,8 @@
},
"name": "type"
},
"static": false,
"kind": "init",
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 239,
@ -933,9 +943,8 @@
},
"value": "B"
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -943,9 +952,8 @@
}
]
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -134,6 +134,8 @@
},
"name": "x"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 14,
@ -149,9 +151,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeProperty",
@ -184,6 +185,8 @@
},
"name": "y"
},
"static": false,
"kind": "init",
"value": {
"type": "StringTypeAnnotation",
"start": 25,
@ -199,9 +202,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -446,6 +448,8 @@
},
"name": "x"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 71,
@ -461,9 +465,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeProperty",
@ -496,6 +499,8 @@
},
"name": "y"
},
"static": false,
"kind": "init",
"value": {
"type": "StringTypeAnnotation",
"start": 82,
@ -511,9 +516,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -858,6 +862,8 @@
},
"name": "a"
},
"static": false,
"kind": "init",
"value": {
"type": "ObjectTypeAnnotation",
"start": 148,
@ -905,6 +911,8 @@
},
"name": "x"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 154,
@ -920,9 +928,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeProperty",
@ -955,6 +962,8 @@
},
"name": "y"
},
"static": false,
"kind": "init",
"value": {
"type": "StringTypeAnnotation",
"start": 165,
@ -970,17 +979,15 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
"exact": true
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeProperty",
@ -1013,6 +1020,8 @@
},
"name": "b"
},
"static": false,
"kind": "init",
"value": {
"type": "BooleanTypeAnnotation",
"start": 179,
@ -1028,9 +1037,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
@ -1378,6 +1386,8 @@
},
"name": "a"
},
"static": false,
"kind": "init",
"value": {
"type": "ObjectTypeAnnotation",
"start": 242,
@ -1425,6 +1435,8 @@
},
"name": "x"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 247,
@ -1440,9 +1452,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeProperty",
@ -1475,6 +1486,8 @@
},
"name": "y"
},
"static": false,
"kind": "init",
"value": {
"type": "StringTypeAnnotation",
"start": 258,
@ -1490,17 +1503,15 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],
"exact": false
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeProperty",
@ -1533,6 +1544,8 @@
},
"name": "b"
},
"static": false,
"kind": "init",
"value": {
"type": "BooleanTypeAnnotation",
"start": 271,
@ -1548,9 +1561,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -107,6 +107,8 @@
},
"name": "p"
},
"static": false,
"kind": "init",
"value": {
"type": "GenericTypeAnnotation",
"start": 13,
@ -140,8 +142,6 @@
"name": "T"
}
},
"optional": false,
"static": false,
"variance": {
"type": "Variance",
"start": 10,
@ -157,7 +157,8 @@
}
},
"kind": "plus"
}
},
"optional": false
}
],
"indexers": [],

View File

@ -107,6 +107,8 @@
},
"name": "p"
},
"static": false,
"kind": "init",
"value": {
"type": "GenericTypeAnnotation",
"start": 13,
@ -140,8 +142,6 @@
"name": "T"
}
},
"optional": false,
"static": false,
"variance": {
"type": "Variance",
"start": 10,
@ -157,7 +157,8 @@
}
},
"kind": "minus"
}
},
"optional": false
}
],
"indexers": [],

View File

@ -107,6 +107,8 @@
},
"name": "p"
},
"static": false,
"kind": "init",
"value": {
"type": "ObjectTypeAnnotation",
"start": 15,
@ -126,9 +128,8 @@
"indexers": [],
"exact": false
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
},
{
"type": "ObjectTypeSpreadProperty",

View File

@ -134,6 +134,8 @@
},
"name": "numVal"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 16,
@ -149,9 +151,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -134,6 +134,8 @@
},
"name": "numVal"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 16,
@ -149,9 +151,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

View File

@ -134,6 +134,8 @@
},
"name": "numVal"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 16,
@ -149,9 +151,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [

View File

@ -148,6 +148,8 @@
},
"name": "numVal"
},
"static": false,
"kind": "init",
"value": {
"type": "NumberTypeAnnotation",
"start": 17,
@ -163,9 +165,8 @@
}
}
},
"optional": false,
"static": false,
"variance": null
"variance": null,
"optional": false
}
],
"indexers": [],

Some files were not shown because too many files have changed in this diff Show More