Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions def/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,10 @@ export default function (fork: Fork) {
def("TSDeclareMethod"),
TSTypeMember
)]);

def("CallExpression")
.bases("TSHasOptionalTypeParameterInstantiation");

def("NewExpression")
.bases("TSHasOptionalTypeParameterInstantiation");
};
9 changes: 6 additions & 3 deletions gen/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ export interface NewExpressionBuilder {
callee: K.ExpressionKind,
comments?: K.CommentKind[] | null,
loc?: K.SourceLocationKind | null,
typeArguments?: null | K.TypeParameterInstantiationKind
typeArguments?: null | K.TypeParameterInstantiationKind,
typeParameters?: null | K.TSTypeParameterInstantiationKind
}
): namedTypes.NewExpression;
}
Expand All @@ -601,7 +602,8 @@ export interface CallExpressionBuilder {
comments?: K.CommentKind[] | null,
loc?: K.SourceLocationKind | null,
optional?: boolean,
typeArguments?: null | K.TypeParameterInstantiationKind
typeArguments?: null | K.TypeParameterInstantiationKind,
typeParameters?: null | K.TSTypeParameterInstantiationKind
}
): namedTypes.CallExpression;
}
Expand Down Expand Up @@ -1192,7 +1194,8 @@ export interface OptionalCallExpressionBuilder {
comments?: K.CommentKind[] | null,
loc?: K.SourceLocationKind | null,
optional?: boolean,
typeArguments?: null | K.TypeParameterInstantiationKind
typeArguments?: null | K.TypeParameterInstantiationKind,
typeParameters?: null | K.TSTypeParameterInstantiationKind
}
): namedTypes.OptionalCallExpression;
}
Expand Down
2 changes: 2 additions & 0 deletions gen/namedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,15 @@ export namespace namedTypes {
callee: K.ExpressionKind;
arguments: (K.ExpressionKind | K.SpreadElementKind)[];
typeArguments?: null | K.TypeParameterInstantiationKind;
typeParameters?: null | K.TSTypeParameterInstantiationKind;
}

export interface CallExpression extends Omit<Expression, "type">, Omit<ChainElement, "type"> {
type: "CallExpression";
callee: K.ExpressionKind;
arguments: (K.ExpressionKind | K.SpreadElementKind)[];
typeArguments?: null | K.TypeParameterInstantiationKind;
typeParameters?: null | K.TSTypeParameterInstantiationKind;
}

export interface RestElement extends Omit<Pattern, "type"> {
Expand Down
24 changes: 24 additions & 0 deletions test/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,30 @@ glob("**/*.ts", {
});
});
});
});

describe('typescript types', () => {
it('Explicit type arguments', function () {
const program = babelParse([
'test<A>();',
'test<B, C>();',
'new test<D>();',
'new test<E, F>();',
].join("\n"), {
plugins: ['typescript']
});

const typeParamNames: any[] = []

visit(program, {
visitTSTypeReference(path: any) {
typeParamNames.push(path.node.typeName.name);
this.traverse(path);
}
});

assert.deepEqual(typeParamNames, ["A", "B", "C", "D", "E", "F"]);
});

describe('scope', () => {
const scope = [
Expand Down