From d7df0b8177ce84262cda8ab074c0bec2df8800ff Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Tue, 29 Oct 2024 10:56:04 -0400 Subject: [PATCH 01/16] refactor: treeshakable kind enum --- src/language/kinds.ts | 74 +++--------------------------------------- src/language/kinds_.ts | 65 +++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 69 deletions(-) create mode 100644 src/language/kinds_.ts diff --git a/src/language/kinds.ts b/src/language/kinds.ts index 52aa7c167a..5bb125d5a8 100644 --- a/src/language/kinds.ts +++ b/src/language/kinds.ts @@ -1,72 +1,8 @@ +import * as kinds_ from './kinds_.js'; // eslint-disable-line + +export * as Kind from './kinds_.js'; + /** * The set of allowed kind values for AST nodes. */ -enum Kind { - /** Name */ - NAME = 'Name', - - /** Document */ - DOCUMENT = 'Document', - OPERATION_DEFINITION = 'OperationDefinition', - VARIABLE_DEFINITION = 'VariableDefinition', - SELECTION_SET = 'SelectionSet', - FIELD = 'Field', - ARGUMENT = 'Argument', - FRAGMENT_ARGUMENT = 'FragmentArgument', - - /** Fragments */ - FRAGMENT_SPREAD = 'FragmentSpread', - INLINE_FRAGMENT = 'InlineFragment', - FRAGMENT_DEFINITION = 'FragmentDefinition', - - /** Values */ - VARIABLE = 'Variable', - INT = 'IntValue', - FLOAT = 'FloatValue', - STRING = 'StringValue', - BOOLEAN = 'BooleanValue', - NULL = 'NullValue', - ENUM = 'EnumValue', - LIST = 'ListValue', - OBJECT = 'ObjectValue', - OBJECT_FIELD = 'ObjectField', - - /** Directives */ - DIRECTIVE = 'Directive', - - /** Types */ - NAMED_TYPE = 'NamedType', - LIST_TYPE = 'ListType', - NON_NULL_TYPE = 'NonNullType', - - /** Type System Definitions */ - SCHEMA_DEFINITION = 'SchemaDefinition', - OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition', - - /** Type Definitions */ - SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition', - OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition', - FIELD_DEFINITION = 'FieldDefinition', - INPUT_VALUE_DEFINITION = 'InputValueDefinition', - INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition', - UNION_TYPE_DEFINITION = 'UnionTypeDefinition', - ENUM_TYPE_DEFINITION = 'EnumTypeDefinition', - ENUM_VALUE_DEFINITION = 'EnumValueDefinition', - INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition', - - /** Directive Definitions */ - DIRECTIVE_DEFINITION = 'DirectiveDefinition', - - /** Type System Extensions */ - SCHEMA_EXTENSION = 'SchemaExtension', - - /** Type Extensions */ - SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension', - OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension', - INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension', - UNION_TYPE_EXTENSION = 'UnionTypeExtension', - ENUM_TYPE_EXTENSION = 'EnumTypeExtension', - INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension', -} - -export { Kind }; +export type Kind = (typeof kinds_)[keyof typeof kinds_]; diff --git a/src/language/kinds_.ts b/src/language/kinds_.ts new file mode 100644 index 0000000000..55b073e5cb --- /dev/null +++ b/src/language/kinds_.ts @@ -0,0 +1,65 @@ +/** Name */ +export const NAME = 'Name'; + +/** Document */ +export const DOCUMENT = 'Document'; +export const OPERATION_DEFINITION = 'OperationDefinition'; +export const VARIABLE_DEFINITION = 'VariableDefinition'; +export const SELECTION_SET = 'SelectionSet'; +export const FIELD = 'Field'; +export const ARGUMENT = 'Argument'; +export const FRAGMENT_ARGUMENT = 'FragmentArgument'; + +/** Fragments */ +export const FRAGMENT_SPREAD = 'FragmentSpread'; +export const INLINE_FRAGMENT = 'InlineFragment'; +export const FRAGMENT_DEFINITION = 'FragmentDefinition'; + +/** Values */ +export const VARIABLE = 'Variable'; +export const INT = 'IntValue'; +export const FLOAT = 'FloatValue'; +export const STRING = 'StringValue'; +export const BOOLEAN = 'BooleanValue'; +export const NULL = 'NullValue'; +export const ENUM = 'EnumValue'; +export const LIST = 'ListValue'; +export const OBJECT = 'ObjectValue'; +export const OBJECT_FIELD = 'ObjectField'; + +/** Directives */ +export const DIRECTIVE = 'Directive'; + +/** Types */ +export const NAMED_TYPE = 'NamedType'; +export const LIST_TYPE = 'ListType'; +export const NON_NULL_TYPE = 'NonNullType'; + +/** Type System Definitions */ +export const SCHEMA_DEFINITION = 'SchemaDefinition'; +export const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition'; + +/** Type Definitions */ +export const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition'; +export const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition'; +export const FIELD_DEFINITION = 'FieldDefinition'; +export const INPUT_VALUE_DEFINITION = 'InputValueDefinition'; +export const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition'; +export const UNION_TYPE_DEFINITION = 'UnionTypeDefinition'; +export const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition'; +export const ENUM_VALUE_DEFINITION = 'EnumValueDefinition'; +export const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition'; + +/** Directive Definitions */ +export const DIRECTIVE_DEFINITION = 'DirectiveDefinition'; + +/** Type System Extensions */ +export const SCHEMA_EXTENSION = 'SchemaExtension'; + +/** Type Extensions */ +export const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension'; +export const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension'; +export const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension'; +export const UNION_TYPE_EXTENSION = 'UnionTypeExtension'; +export const ENUM_TYPE_EXTENSION = 'EnumTypeExtension'; +export const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension'; From 05b06d4f07aec1bb27ddc6fc790dc06f78a2829c Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 08:53:29 -0500 Subject: [PATCH 02/16] allow type level namespace access too --- src/language/kinds.ts | 7 ------- src/language/kinds_.ts | 43 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/language/kinds.ts b/src/language/kinds.ts index 5bb125d5a8..d088eaad6a 100644 --- a/src/language/kinds.ts +++ b/src/language/kinds.ts @@ -1,8 +1 @@ -import * as kinds_ from './kinds_.js'; // eslint-disable-line - export * as Kind from './kinds_.js'; - -/** - * The set of allowed kind values for AST nodes. - */ -export type Kind = (typeof kinds_)[keyof typeof kinds_]; diff --git a/src/language/kinds_.ts b/src/language/kinds_.ts index 55b073e5cb..c1e2deb031 100644 --- a/src/language/kinds_.ts +++ b/src/language/kinds_.ts @@ -3,63 +3,104 @@ export const NAME = 'Name'; /** Document */ export const DOCUMENT = 'Document'; +export type DOCUMENT = typeof DOCUMENT; export const OPERATION_DEFINITION = 'OperationDefinition'; +export type OPERATION_DEFINITION = typeof OPERATION_DEFINITION; export const VARIABLE_DEFINITION = 'VariableDefinition'; +export type VARIABLE_DEFINITION = typeof VARIABLE_DEFINITION; export const SELECTION_SET = 'SelectionSet'; +export type SELECTION_SET = typeof SELECTION_SET; export const FIELD = 'Field'; +export type FIELD = typeof FIELD; export const ARGUMENT = 'Argument'; +export type ARGUMENT = typeof ARGUMENT; export const FRAGMENT_ARGUMENT = 'FragmentArgument'; +export type FRAGMENT_ARGUMENT = typeof FRAGMENT_ARGUMENT; /** Fragments */ export const FRAGMENT_SPREAD = 'FragmentSpread'; +export type FRAGMENT_SPREAD = typeof FRAGMENT_SPREAD; export const INLINE_FRAGMENT = 'InlineFragment'; +export type INLINE_FRAGMENT = typeof INLINE_FRAGMENT; export const FRAGMENT_DEFINITION = 'FragmentDefinition'; +export type FRAGMENT_DEFINITION = typeof FRAGMENT_DEFINITION; /** Values */ export const VARIABLE = 'Variable'; +export type VARIABLE = typeof VARIABLE; export const INT = 'IntValue'; +export type INT = typeof INT; export const FLOAT = 'FloatValue'; +export type FLOAT = typeof FLOAT; export const STRING = 'StringValue'; +export type STRING = typeof STRING; export const BOOLEAN = 'BooleanValue'; +export type BOOLEAN = typeof BOOLEAN; export const NULL = 'NullValue'; +export type NULL = typeof NULL; export const ENUM = 'EnumValue'; +export type ENUM = typeof ENUM; export const LIST = 'ListValue'; +export type LIST = typeof LIST; export const OBJECT = 'ObjectValue'; +export type OBJECT = typeof OBJECT; export const OBJECT_FIELD = 'ObjectField'; +export type OBJECT_FIELD = typeof OBJECT_FIELD; /** Directives */ export const DIRECTIVE = 'Directive'; +export type DIRECTIVE = typeof DIRECTIVE; /** Types */ export const NAMED_TYPE = 'NamedType'; +export type NAMED_TYPE = typeof NAMED_TYPE; export const LIST_TYPE = 'ListType'; +export type LIST_TYPE = typeof LIST_TYPE; export const NON_NULL_TYPE = 'NonNullType'; +export type NON_NULL_TYPE = typeof NON_NULL_TYPE; /** Type System Definitions */ export const SCHEMA_DEFINITION = 'SchemaDefinition'; +export type SCHEMA_DEFINITION = typeof SCHEMA_DEFINITION; export const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition'; +export type OPERATION_TYPE_DEFINITION = typeof OPERATION_TYPE_DEFINITION; /** Type Definitions */ export const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition'; +export type SCALAR_TYPE_DEFINITION = typeof SCALAR_TYPE_DEFINITION; export const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition'; +export type OBJECT_TYPE_DEFINITION = typeof OBJECT_TYPE_DEFINITION; export const FIELD_DEFINITION = 'FieldDefinition'; +export type FIELD_DEFINITION = typeof FIELD_DEFINITION; export const INPUT_VALUE_DEFINITION = 'InputValueDefinition'; +export type INPUT_VALUE_DEFINITION = typeof INPUT_VALUE_DEFINITION; export const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition'; +export type INTERFACE_TYPE_DEFINITION = typeof INTERFACE_TYPE_DEFINITION; export const UNION_TYPE_DEFINITION = 'UnionTypeDefinition'; +export type UNION_TYPE_DEFINITION = typeof UNION_TYPE_DEFINITION; export const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition'; export const ENUM_VALUE_DEFINITION = 'EnumValueDefinition'; +export type ENUM_VALUE_DEFINITION = typeof ENUM_VALUE_DEFINITION; export const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition'; +export type INPUT_OBJECT_TYPE_DEFINITION = typeof INPUT_OBJECT_TYPE_DEFINITION; /** Directive Definitions */ export const DIRECTIVE_DEFINITION = 'DirectiveDefinition'; - +export type DIRECTIVE_DEFINITION = typeof DIRECTIVE_DEFINITION; /** Type System Extensions */ export const SCHEMA_EXTENSION = 'SchemaExtension'; +export type SCHEMA_EXTENSION = typeof SCHEMA_EXTENSION; /** Type Extensions */ export const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension'; +export type SCALAR_TYPE_EXTENSION = typeof SCALAR_TYPE_EXTENSION; export const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension'; +export type OBJECT_TYPE_EXTENSION = typeof OBJECT_TYPE_EXTENSION; export const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension'; +export type INTERFACE_TYPE_EXTENSION = typeof INTERFACE_TYPE_EXTENSION; export const UNION_TYPE_EXTENSION = 'UnionTypeExtension'; +export type UNION_TYPE_EXTENSION = typeof UNION_TYPE_EXTENSION; export const ENUM_TYPE_EXTENSION = 'EnumTypeExtension'; +export type ENUM_TYPE_EXTENSION = typeof ENUM_TYPE_EXTENSION; export const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension'; +export type INPUT_OBJECT_TYPE_EXTENSION = typeof INPUT_OBJECT_TYPE_EXTENSION; From 05dfc0d8b23e8accac1757c20b8713ad07d95ea4 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:02:05 -0500 Subject: [PATCH 03/16] disable eslint rule --- package.json | 3 ++- src/language/kinds_.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7399802238..f500fc6f06 100644 --- a/package.json +++ b/package.json @@ -92,5 +92,6 @@ }, "publishConfig": { "tag": "alpha" - } + }, + "packageManager": "pnpm@8.12.1+sha512.6705ea1966adb6587053e6cfe6fddc377f81066228daf736c4490012f44f2ff1bf0c713bb8f3145fce0e3ef669c7c15f19a59ac157838951f234c17b81ca655d" } diff --git a/src/language/kinds_.ts b/src/language/kinds_.ts index c1e2deb031..10b9d645a2 100644 --- a/src/language/kinds_.ts +++ b/src/language/kinds_.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-redeclare */ + /** Name */ export const NAME = 'Name'; From cece3f72d71f05e24ff6ef97b2935f4428bbdac1 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:05:17 -0500 Subject: [PATCH 04/16] bring back type --- src/language/kinds.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/language/kinds.ts b/src/language/kinds.ts index d088eaad6a..36231d3135 100644 --- a/src/language/kinds.ts +++ b/src/language/kinds.ts @@ -1 +1,6 @@ +/* eslint-disable import/no-namespace */ +import type * as Kind_ from './kinds_.js'; + export * as Kind from './kinds_.js'; + +export type Kind = (typeof Kind_)[keyof typeof Kind_]; From 3f99d7d542139c815e16ff3004f06a7520b3e00b Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:13:37 -0500 Subject: [PATCH 05/16] no test unsupported ts versions --- integrationTests/ts/package.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/integrationTests/ts/package.json b/integrationTests/ts/package.json index 9019b51b68..6e5bfb367d 100644 --- a/integrationTests/ts/package.json +++ b/integrationTests/ts/package.json @@ -8,11 +8,6 @@ "dependencies": { "graphql": "file:../graphql.tgz", "graphql-esm": "file:../graphql-esm.tgz", - "typescript-4.4": "npm:typescript@4.4.x", - "typescript-4.5": "npm:typescript@4.5.x", - "typescript-4.6": "npm:typescript@4.6.x", - "typescript-4.7": "npm:typescript@4.7.x", - "typescript-4.8": "npm:typescript@4.8.x", "typescript-4.9": "npm:typescript@4.9.x", "typescript-5.0": "npm:typescript@5.0.x", "typescript-5.1": "npm:typescript@5.1.x", From 0608c668ffd727c24787ecfb125d90cd594ba4fa Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:15:04 -0500 Subject: [PATCH 06/16] no pnpm --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index f500fc6f06..7399802238 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,5 @@ }, "publishConfig": { "tag": "alpha" - }, - "packageManager": "pnpm@8.12.1+sha512.6705ea1966adb6587053e6cfe6fddc377f81066228daf736c4490012f44f2ff1bf0c713bb8f3145fce0e3ef669c7c15f19a59ac157838951f234c17b81ca655d" + } } From aee14a0e55e074a4398ebfc961db887bbb3cb38e Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:27:46 -0500 Subject: [PATCH 07/16] fix alpha test order --- src/language/__tests__/predicates-test.ts | 78 +++++++++++------------ 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/language/__tests__/predicates-test.ts b/src/language/__tests__/predicates-test.ts index 350e3f1a6b..7eeb682f3f 100644 --- a/src/language/__tests__/predicates-test.ts +++ b/src/language/__tests__/predicates-test.ts @@ -27,30 +27,30 @@ function filterNodes(predicate: (node: ASTNode) => boolean): Array { describe('AST node predicates', () => { it('isDefinitionNode', () => { expect(filterNodes(isDefinitionNode)).to.deep.equal([ - 'OperationDefinition', - 'FragmentDefinition', - 'SchemaDefinition', - 'ScalarTypeDefinition', - 'ObjectTypeDefinition', - 'InterfaceTypeDefinition', - 'UnionTypeDefinition', + 'DirectiveDefinition', 'EnumTypeDefinition', + 'EnumTypeExtension', + 'FragmentDefinition', 'InputObjectTypeDefinition', - 'DirectiveDefinition', - 'SchemaExtension', - 'ScalarTypeExtension', - 'ObjectTypeExtension', + 'InputObjectTypeExtension', + 'InterfaceTypeDefinition', 'InterfaceTypeExtension', + 'ObjectTypeDefinition', + 'ObjectTypeExtension', + 'OperationDefinition', + 'ScalarTypeDefinition', + 'ScalarTypeExtension', + 'SchemaDefinition', + 'SchemaExtension', + 'UnionTypeDefinition', 'UnionTypeExtension', - 'EnumTypeExtension', - 'InputObjectTypeExtension', ]); }); it('isExecutableDefinitionNode', () => { expect(filterNodes(isExecutableDefinitionNode)).to.deep.equal([ - 'OperationDefinition', 'FragmentDefinition', + 'OperationDefinition', ]); }); @@ -64,15 +64,15 @@ describe('AST node predicates', () => { it('isValueNode', () => { expect(filterNodes(isValueNode)).to.deep.equal([ - 'Variable', - 'IntValue', - 'FloatValue', - 'StringValue', 'BooleanValue', - 'NullValue', 'EnumValue', + 'FloatValue', + 'IntValue', 'ListValue', + 'NullValue', 'ObjectValue', + 'StringValue', + 'Variable', ]); }); @@ -89,56 +89,56 @@ describe('AST node predicates', () => { it('isTypeNode', () => { expect(filterNodes(isTypeNode)).to.deep.equal([ - 'NamedType', 'ListType', + 'NamedType', 'NonNullType', ]); }); it('isTypeSystemDefinitionNode', () => { expect(filterNodes(isTypeSystemDefinitionNode)).to.deep.equal([ - 'SchemaDefinition', - 'ScalarTypeDefinition', - 'ObjectTypeDefinition', - 'InterfaceTypeDefinition', - 'UnionTypeDefinition', + 'DirectiveDefinition', 'EnumTypeDefinition', 'InputObjectTypeDefinition', - 'DirectiveDefinition', + 'InterfaceTypeDefinition', + 'ObjectTypeDefinition', + 'ScalarTypeDefinition', + 'SchemaDefinition', + 'UnionTypeDefinition', ]); }); it('isTypeDefinitionNode', () => { expect(filterNodes(isTypeDefinitionNode)).to.deep.equal([ - 'ScalarTypeDefinition', - 'ObjectTypeDefinition', - 'InterfaceTypeDefinition', - 'UnionTypeDefinition', 'EnumTypeDefinition', 'InputObjectTypeDefinition', + 'InterfaceTypeDefinition', + 'ObjectTypeDefinition', + 'ScalarTypeDefinition', + 'UnionTypeDefinition', ]); }); it('isTypeSystemExtensionNode', () => { expect(filterNodes(isTypeSystemExtensionNode)).to.deep.equal([ - 'SchemaExtension', - 'ScalarTypeExtension', - 'ObjectTypeExtension', - 'InterfaceTypeExtension', - 'UnionTypeExtension', 'EnumTypeExtension', 'InputObjectTypeExtension', + 'InterfaceTypeExtension', + 'ObjectTypeExtension', + 'ScalarTypeExtension', + 'SchemaExtension', + 'UnionTypeExtension', ]); }); it('isTypeExtensionNode', () => { expect(filterNodes(isTypeExtensionNode)).to.deep.equal([ - 'ScalarTypeExtension', - 'ObjectTypeExtension', - 'InterfaceTypeExtension', - 'UnionTypeExtension', 'EnumTypeExtension', 'InputObjectTypeExtension', + 'InterfaceTypeExtension', + 'ObjectTypeExtension', + 'ScalarTypeExtension', + 'UnionTypeExtension', ]); }); }); From 323d12ef877f86b493549b7134ba0b91e5b2c0e1 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:35:11 -0500 Subject: [PATCH 08/16] fix lints --- src/index.ts | 6 +++++- src/language/index.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index aef9d75b16..62ec7b0239 100644 --- a/src/index.ts +++ b/src/index.ts @@ -206,6 +206,11 @@ export type { } from './type/index.js'; // Parse and operate on GraphQL language source files. +export { + // eslint-disable-line @typescript-eslint/consistent-type-exports + Kind, +} from './language/kinds.js'; + export { Token, Source, @@ -230,7 +235,6 @@ export { visitInParallel, getEnterLeaveForKind, BREAK, - Kind, DirectiveLocation, // Predicates isDefinitionNode, diff --git a/src/language/index.ts b/src/language/index.ts index 4d96766abc..3dfb23a056 100644 --- a/src/language/index.ts +++ b/src/language/index.ts @@ -5,7 +5,7 @@ export type { SourceLocation } from './location.js'; export { printLocation, printSourceLocation } from './printLocation.js'; -export { Kind } from './kinds.js'; +export { Kind } from './kinds.js'; // eslint-disable-line @typescript-eslint/consistent-type-exports export { TokenKind } from './tokenKind.js'; From 17447056a4d0273d8812e19adc8aefe1cf89abc4 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:43:38 -0500 Subject: [PATCH 09/16] fix lint again --- src/language/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/language/index.ts b/src/language/index.ts index 3dfb23a056..fe3ac04233 100644 --- a/src/language/index.ts +++ b/src/language/index.ts @@ -5,7 +5,8 @@ export type { SourceLocation } from './location.js'; export { printLocation, printSourceLocation } from './printLocation.js'; -export { Kind } from './kinds.js'; // eslint-disable-line @typescript-eslint/consistent-type-exports +// eslint-disable-next-line @typescript-eslint/consistent-type-exports +export { Kind } from './kinds.js'; export { TokenKind } from './tokenKind.js'; From 64d7b51e667fa054f94de99de2f4c8fc67227bef Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:45:58 -0500 Subject: [PATCH 10/16] fix lint again --- src/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 62ec7b0239..0ab5b6cb65 100644 --- a/src/index.ts +++ b/src/index.ts @@ -206,10 +206,8 @@ export type { } from './type/index.js'; // Parse and operate on GraphQL language source files. -export { - // eslint-disable-line @typescript-eslint/consistent-type-exports - Kind, -} from './language/kinds.js'; +// eslint-disable-next-line @typescript-eslint/consistent-type-exports +export { Kind } from './language/kinds.js'; export { Token, From 62ed7e7957e26c9900be5cc7ba2070066cf5d41f Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:46:11 -0500 Subject: [PATCH 11/16] spaces --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 0ab5b6cb65..4e272f79eb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -208,7 +208,6 @@ export type { // Parse and operate on GraphQL language source files. // eslint-disable-next-line @typescript-eslint/consistent-type-exports export { Kind } from './language/kinds.js'; - export { Token, Source, From e6900e07387effe9a879df0686c87dea9187dca2 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:50:50 -0500 Subject: [PATCH 12/16] lint links --- src/index.ts | 1 + src/language/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/index.ts b/src/index.ts index 4e272f79eb..aa3153b5f7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -206,6 +206,7 @@ export type { } from './type/index.js'; // Parse and operate on GraphQL language source files. +// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313 // eslint-disable-next-line @typescript-eslint/consistent-type-exports export { Kind } from './language/kinds.js'; export { diff --git a/src/language/index.ts b/src/language/index.ts index fe3ac04233..706072a75b 100644 --- a/src/language/index.ts +++ b/src/language/index.ts @@ -5,6 +5,7 @@ export type { SourceLocation } from './location.js'; export { printLocation, printSourceLocation } from './printLocation.js'; +// @see https://github.com/typescript-eslint/typescript-eslint/issues/10313 // eslint-disable-next-line @typescript-eslint/consistent-type-exports export { Kind } from './kinds.js'; From df5e4f6226d64c129e918e44ef3fd7fcdfe47e22 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 09:58:29 -0500 Subject: [PATCH 13/16] missing type def --- src/language/kinds_.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/language/kinds_.ts b/src/language/kinds_.ts index 10b9d645a2..b034035fa0 100644 --- a/src/language/kinds_.ts +++ b/src/language/kinds_.ts @@ -2,6 +2,7 @@ /** Name */ export const NAME = 'Name'; +export type NAME = typeof NAME; /** Document */ export const DOCUMENT = 'Document'; From dc3e67c73391ae5bf1895020278ea067894965ac Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 10:05:48 -0500 Subject: [PATCH 14/16] add some test coverage --- src/language/__tests__/kind-test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/language/__tests__/kind-test.ts diff --git a/src/language/__tests__/kind-test.ts b/src/language/__tests__/kind-test.ts new file mode 100644 index 0000000000..4eaf75148b --- /dev/null +++ b/src/language/__tests__/kind-test.ts @@ -0,0 +1,29 @@ +/* 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; + }); +}); From b47835598d31ae28aa6f1c80867dcf36c357954a Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 10:06:13 -0500 Subject: [PATCH 15/16] spacing --- src/language/__tests__/kind-test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/language/__tests__/kind-test.ts b/src/language/__tests__/kind-test.ts index 4eaf75148b..febea2414f 100644 --- a/src/language/__tests__/kind-test.ts +++ b/src/language/__tests__/kind-test.ts @@ -12,6 +12,7 @@ describe('Kind', () => { 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'; From a9982fa7e0e212e49c2d910bb76515f32d08771f Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 9 Nov 2024 10:09:31 -0500 Subject: [PATCH 16/16] spacing --- src/language/kinds_.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/language/kinds_.ts b/src/language/kinds_.ts index b034035fa0..0389c60c75 100644 --- a/src/language/kinds_.ts +++ b/src/language/kinds_.ts @@ -90,6 +90,7 @@ export type INPUT_OBJECT_TYPE_DEFINITION = typeof INPUT_OBJECT_TYPE_DEFINITION; /** Directive Definitions */ export const DIRECTIVE_DEFINITION = 'DirectiveDefinition'; export type DIRECTIVE_DEFINITION = typeof DIRECTIVE_DEFINITION; + /** Type System Extensions */ export const SCHEMA_EXTENSION = 'SchemaExtension'; export type SCHEMA_EXTENSION = typeof SCHEMA_EXTENSION;