-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f579f1
commit 0b53e3d
Showing
24 changed files
with
455 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as ts from "typescript"; | ||
|
||
export function prefixNode(node: ts.Node, prefix: string): ts.FileTextChanges { | ||
const start = node.getStart(); | ||
return { | ||
fileName: node.getSourceFile().fileName, | ||
textChanges: [{ span: { start, length: 0 }, newText: prefix }], | ||
}; | ||
} | ||
|
||
export function removeNode(node: ts.Node): ts.FileTextChanges { | ||
const start = node.getStart(); | ||
const length = node.getEnd() - start; | ||
return { | ||
fileName: node.getSourceFile().fileName, | ||
textChanges: [{ span: { start, length }, newText: "" }], | ||
}; | ||
} | ||
|
||
export function replaceNode(node: ts.Node, newText): ts.FileTextChanges { | ||
const start = node.getStart(); | ||
const length = node.getEnd() - start; | ||
return { | ||
fileName: node.getSourceFile().fileName, | ||
textChanges: [{ span: { start, length }, newText }], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @gqlField */ | ||
async function greet(_: Query): Promise<string> { | ||
return "Hello, World!"; | ||
} | ||
|
||
/** @gqlType */ | ||
export type Query = unknown; |
23 changes: 23 additions & 0 deletions
23
src/tests/codeActions/asyncFunctionFieldNotExported.ts.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlField */ | ||
async function greet(_: Query): Promise<string> { | ||
return "Hello, World!"; | ||
} | ||
|
||
/** @gqlType */ | ||
export type Query = unknown; | ||
|
||
----------------- | ||
OUTPUT | ||
----------------- | ||
- Expected | ||
+ Received | ||
|
||
@@ -1,5 +1,5 @@ | ||
/** @gqlField */ | ||
- async function greet(_: Query): Promise<string> { | ||
+ export async function greet(_: Query): Promise<string> { | ||
return "Hello, World!"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** @gqlType */ | ||
class User { | ||
/** @gqlField */ | ||
name: string; | ||
|
||
/** @gqlField */ | ||
static getUser(_: Query): User { | ||
return new User(); | ||
} | ||
} | ||
|
||
/** @gqlType */ | ||
export type Query = unknown; |
29 changes: 29 additions & 0 deletions
29
src/tests/codeActions/classWithStaticMethodNotExported.ts.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlType */ | ||
class User { | ||
/** @gqlField */ | ||
name: string; | ||
|
||
/** @gqlField */ | ||
static getUser(_: Query): User { | ||
return new User(); | ||
} | ||
} | ||
|
||
/** @gqlType */ | ||
export type Query = unknown; | ||
|
||
----------------- | ||
OUTPUT | ||
----------------- | ||
- Expected | ||
+ Received | ||
|
||
@@ -1,5 +1,5 @@ | ||
/** @gqlType */ | ||
- class User { | ||
+ export class User { | ||
/** @gqlField */ | ||
name: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @gqlField */ | ||
function greet(_: Query): string { | ||
return "Hello, World!"; | ||
} | ||
|
||
/** @gqlType */ | ||
type Query = unknown; |
23 changes: 23 additions & 0 deletions
23
src/tests/codeActions/functionFieldNotExported.ts.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlField */ | ||
function greet(_: Query): string { | ||
return "Hello, World!"; | ||
} | ||
|
||
/** @gqlType */ | ||
type Query = unknown; | ||
|
||
----------------- | ||
OUTPUT | ||
----------------- | ||
- Expected | ||
+ Received | ||
|
||
@@ -1,5 +1,5 @@ | ||
/** @gqlField */ | ||
- function greet(_: Query): string { | ||
+ export function greet(_: Query): string { | ||
return "Hello, World!"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* @gqlType | ||
* @killsParentOnException | ||
*/ | ||
type Query = unknown; |
Oops, something went wrong.