forked from graphql/graphql-js
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: treeshakable kind enum (graphql#4270)
closes graphql#4253
- Loading branch information
1 parent
92d4ed0
commit 079167d
Showing
7 changed files
with
188 additions
and
115 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 |
---|---|---|
|
@@ -8,11 +8,6 @@ | |
"dependencies": { | ||
"graphql": "file:../graphql.tgz", | ||
"graphql-esm": "file:../graphql-esm.tgz", | ||
"typescript-4.4": "npm:[email protected]", | ||
"typescript-4.5": "npm:[email protected]", | ||
"typescript-4.6": "npm:[email protected]", | ||
"typescript-4.7": "npm:[email protected]", | ||
"typescript-4.8": "npm:[email protected]", | ||
"typescript-4.9": "npm:[email protected]", | ||
"typescript-5.0": "npm:[email protected]", | ||
"typescript-5.1": "npm:[email protected]", | ||
|
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,30 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-expressions */ | ||
import { describe, it } from 'mocha'; | ||
|
||
import { Kind } from '../index.js'; | ||
|
||
describe('Kind', () => { | ||
it('is a term level namespace with term level enum members', () => { | ||
const a: Kind.NAME = Kind.NAME; | ||
a; | ||
const b: Kind = Kind.NAME; | ||
b; | ||
const c: Kind = Kind.ARGUMENT; | ||
c; | ||
}); | ||
|
||
it('is a type level namespace with type level enum members', () => { | ||
// @ts-expect-error | ||
const a: Kind.NAME = 'bad'; | ||
a; | ||
const b: Kind.NAME = 'Name'; | ||
b; | ||
// @ts-expect-error | ||
const c: Kind = 'bad'; | ||
c; | ||
const d: Kind = 'Name'; | ||
d; | ||
const e: Kind = 'Argument'; | ||
e; | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,72 +1,6 @@ | ||
/** | ||
* The set of allowed kind values for AST nodes. | ||
*/ | ||
export const Kind = { | ||
/** Name */ | ||
NAME: 'Name' as const, | ||
/* eslint-disable import/no-namespace */ | ||
import type * as Kind_ from './kinds_.js'; | ||
|
||
/** Document */ | ||
DOCUMENT: 'Document' as const, | ||
OPERATION_DEFINITION: 'OperationDefinition' as const, | ||
VARIABLE_DEFINITION: 'VariableDefinition' as const, | ||
SELECTION_SET: 'SelectionSet' as const, | ||
FIELD: 'Field' as const, | ||
ARGUMENT: 'Argument' as const, | ||
FRAGMENT_ARGUMENT: 'FragmentArgument' as const, | ||
export * as Kind from './kinds_.js'; | ||
|
||
/** Fragments */ | ||
FRAGMENT_SPREAD: 'FragmentSpread' as const, | ||
INLINE_FRAGMENT: 'InlineFragment' as const, | ||
FRAGMENT_DEFINITION: 'FragmentDefinition' as const, | ||
|
||
/** Values */ | ||
VARIABLE: 'Variable' as const, | ||
INT: 'IntValue' as const, | ||
FLOAT: 'FloatValue' as const, | ||
STRING: 'StringValue' as const, | ||
BOOLEAN: 'BooleanValue' as const, | ||
NULL: 'NullValue' as const, | ||
ENUM: 'EnumValue' as const, | ||
LIST: 'ListValue' as const, | ||
OBJECT: 'ObjectValue' as const, | ||
OBJECT_FIELD: 'ObjectField' as const, | ||
|
||
/** Directives */ | ||
DIRECTIVE: 'Directive' as const, | ||
|
||
/** Types */ | ||
NAMED_TYPE: 'NamedType' as const, | ||
LIST_TYPE: 'ListType' as const, | ||
NON_NULL_TYPE: 'NonNullType' as const, | ||
|
||
/** Type System Definitions */ | ||
SCHEMA_DEFINITION: 'SchemaDefinition' as const, | ||
OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition' as const, | ||
|
||
/** Type Definitions */ | ||
SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition' as const, | ||
OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition' as const, | ||
FIELD_DEFINITION: 'FieldDefinition' as const, | ||
INPUT_VALUE_DEFINITION: 'InputValueDefinition' as const, | ||
INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition' as const, | ||
UNION_TYPE_DEFINITION: 'UnionTypeDefinition' as const, | ||
ENUM_TYPE_DEFINITION: 'EnumTypeDefinition' as const, | ||
ENUM_VALUE_DEFINITION: 'EnumValueDefinition' as const, | ||
INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition' as const, | ||
|
||
/** Directive Definitions */ | ||
DIRECTIVE_DEFINITION: 'DirectiveDefinition' as const, | ||
|
||
/** Type System Extensions */ | ||
SCHEMA_EXTENSION: 'SchemaExtension' as const, | ||
|
||
/** Type Extensions */ | ||
SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension' as const, | ||
OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension' as const, | ||
INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension' as const, | ||
UNION_TYPE_EXTENSION: 'UnionTypeExtension' as const, | ||
ENUM_TYPE_EXTENSION: 'EnumTypeExtension' as const, | ||
INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension' as const, | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-redeclare | ||
export type Kind = (typeof Kind)[keyof typeof Kind]; | ||
export type Kind = (typeof Kind_)[keyof typeof Kind_]; |
Oops, something went wrong.