Skip to content

Commit

Permalink
feat: handle Promise type reference
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkyao committed Nov 7, 2018
1 parent bf087cb commit f3fa881
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion demo/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export type EntryType = {
}

export interface Mutation {
create(input: CreateInput): MutationResult
create(input: CreateInput): Promise<MutationResult>
}

interface CreateInput {
Expand Down
2 changes: 1 addition & 1 deletion demo/debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -2752,7 +2752,7 @@
"position": {
"file": "demo/cases.ts",
"line": 358,
"character": 30
"character": 38
}
},
"parameters": [
Expand Down
2 changes: 1 addition & 1 deletion online/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export type EntryType = {
}
export interface Mutation {
create(input: CreateInput): MutationResult
create(input: CreateInput): Promise<MutationResult>
}
interface CreateInput {
Expand Down
6 changes: 6 additions & 0 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,12 @@ export class Parser {
if (reference.typeName.text === 'Array') {
return this.getTypeOfArrayTypeReference(reference, sourceFile)
}
if (reference.typeName.text === 'Promise' && reference.typeArguments && reference.typeArguments.length > 0) {
const typeArgument = reference.typeArguments[0]
if (typeArgument.kind === ts.SyntaxKind.TypeReference) {
return this.getTypeOfTypeReference(typeArgument as ts.TypeReferenceNode, sourceFile)
}
}
return {
kind: 'reference',
name: reference.typeName.text,
Expand Down

0 comments on commit f3fa881

Please sign in to comment.