Skip to content

Commit

Permalink
fix: discrepancies between Flow and TS types (#3001)
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Mar 30, 2021
1 parent 2616dc7 commit 58b9cd5
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/language/blockString.d.ts
Expand Up @@ -3,6 +3,8 @@
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
*
* This implements the GraphQL spec's BlockStringValue() static algorithm.
*
* @internal
*/
export function dedentBlockStringValue(rawString: string): string;

Expand All @@ -15,6 +17,8 @@ export function getBlockStringIndentation(body: string): number;
* Print a block string in the indented block form by adding a leading and
* trailing blank line. However, if a block string starts with whitespace and is
* a single-line, adding a leading blank line would strip that whitespace.
*
* @internal
*/
export function printBlockString(
value: string,
Expand Down
4 changes: 2 additions & 2 deletions src/language/directiveLocation.d.ts
@@ -1,7 +1,7 @@
/**
* The set of allowed directive location values.
*/
export const DirectiveLocation: {
export const DirectiveLocation: Readonly<{
// Request Definitions
QUERY: 'QUERY';
MUTATION: 'MUTATION';
Expand All @@ -24,7 +24,7 @@ export const DirectiveLocation: {
ENUM_VALUE: 'ENUM_VALUE';
INPUT_OBJECT: 'INPUT_OBJECT';
INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION';
};
}>;

/**
* The enum type representing the directive location values.
Expand Down
4 changes: 2 additions & 2 deletions src/language/kinds.d.ts
@@ -1,7 +1,7 @@
/**
* The set of allowed kind values for AST nodes.
*/
export const Kind: {
export const Kind: Readonly<{
// Name
NAME: 'Name';

Expand Down Expand Up @@ -66,7 +66,7 @@ export const Kind: {
UNION_TYPE_EXTENSION: 'UnionTypeExtension';
ENUM_TYPE_EXTENSION: 'EnumTypeExtension';
INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension';
};
}>;

/**
* The enum type representing the possible kind values of AST nodes.
Expand Down
5 changes: 0 additions & 5 deletions src/language/lexer.d.ts
Expand Up @@ -47,11 +47,6 @@ export class Lexer {
lookahead(): Token;
}

/**
* @internal
*/
export function isPunctuatorToken(token: Token): boolean;

/**
* @internal
*/
Expand Down
1 change: 1 addition & 0 deletions src/language/source.d.ts
Expand Up @@ -15,6 +15,7 @@ export class Source {
name: string;
locationOffset: Location;
constructor(body: string, name?: string, locationOffset?: Location);
get [Symbol.toStringTag](): string;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/language/tokenKind.d.ts
Expand Up @@ -2,7 +2,7 @@
* An exported enum describing the different kinds of tokens that the
* lexer emits.
*/
export const TokenKind: {
export const TokenKind: Readonly<{
SOF: '<SOF>';
EOF: '<EOF>';
BANG: '!';
Expand All @@ -25,7 +25,7 @@ export const TokenKind: {
STRING: 'String';
BLOCK_STRING: 'BlockString';
COMMENT: 'Comment';
};
}>;

/**
* The enum type representing the token kinds values.
Expand Down
7 changes: 7 additions & 0 deletions src/type/definition.d.ts
Expand Up @@ -180,6 +180,7 @@ export class GraphQLList<T extends GraphQLType> {
toString: () => string;
toJSON: () => string;
inspect: () => string;
get [Symbol.toStringTag](): string;
}

/**
Expand Down Expand Up @@ -210,6 +211,7 @@ export class GraphQLNonNull<T extends GraphQLNullableType> {
toString: () => string;
toJSON: () => string;
inspect: () => string;
get [Symbol.toStringTag](): string;
}

export type GraphQLWrappingType = GraphQLList<any> | GraphQLNonNull<any>;
Expand Down Expand Up @@ -426,6 +428,7 @@ export class GraphQLObjectType<TSource = any, TContext = any> {
toString(): string;
toJSON(): string;
inspect(): string;
get [Symbol.toStringTag](): string;
}

export function argsToArgsConfig(
Expand Down Expand Up @@ -632,6 +635,7 @@ export class GraphQLInterfaceType {
toString(): string;
toJSON(): string;
inspect(): string;
get [Symbol.toStringTag](): string;
}

export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
Expand Down Expand Up @@ -706,6 +710,7 @@ export class GraphQLUnionType {
toString(): string;
toJSON(): string;
inspect(): string;
get [Symbol.toStringTag](): string;
}

export interface GraphQLUnionTypeConfig<TSource, TContext> {
Expand Down Expand Up @@ -782,6 +787,7 @@ export class GraphQLEnumType {
toString(): string;
toJSON(): string;
inspect(): string;
get [Symbol.toStringTag](): string;
}

export interface GraphQLEnumTypeConfig {
Expand Down Expand Up @@ -879,6 +885,7 @@ export class GraphQLInputObjectType {
toString(): string;
toJSON(): string;
inspect(): string;
get [Symbol.toStringTag](): string;
}

export interface GraphQLInputObjectTypeConfig {
Expand Down
1 change: 1 addition & 0 deletions src/type/directives.d.ts
Expand Up @@ -51,6 +51,7 @@ export class GraphQLDirective {
toString(): string;
toJSON(): string;
inspect(): string;
get [Symbol.toStringTag](): string;
}

export interface GraphQLDirectiveConfig {
Expand Down
4 changes: 2 additions & 2 deletions src/type/introspection.d.ts
Expand Up @@ -13,7 +13,7 @@ export const __Field: GraphQLObjectType;
export const __InputValue: GraphQLObjectType;
export const __EnumValue: GraphQLObjectType;

export const TypeKind: {
export const TypeKind: Readonly<{
SCALAR: 'SCALAR';
OBJECT: 'OBJECT';
INTERFACE: 'INTERFACE';
Expand All @@ -22,7 +22,7 @@ export const TypeKind: {
INPUT_OBJECT: 'INPUT_OBJECT';
LIST: 'LIST';
NON_NULL: 'NON_NULL';
};
}>;

export const __TypeKind: GraphQLEnumType;

Expand Down
3 changes: 2 additions & 1 deletion src/type/schema.d.ts
Expand Up @@ -81,7 +81,7 @@ export class GraphQLSchema {

isSubType(
abstractType: GraphQLAbstractType,
maybeSubType: GraphQLNamedType,
maybeSubType: GraphQLObjectType | GraphQLInterfaceType,
): boolean;

getDirectives(): ReadonlyArray<GraphQLDirective>;
Expand All @@ -94,6 +94,7 @@ export class GraphQLSchema {
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
assumeValid: boolean;
};
get [Symbol.toStringTag](): string;
}

interface TypeMap {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/TypeInfo.d.ts
Expand Up @@ -34,7 +34,7 @@ export class TypeInfo {
getParentType(): Maybe<GraphQLCompositeType>;
getInputType(): Maybe<GraphQLInputType>;
getParentInputType(): Maybe<GraphQLInputType>;
getFieldDef(): GraphQLField<any, Maybe<any>>;
getFieldDef(): Maybe<GraphQLField<any, any>>;
getDefaultValue(): Maybe<any>;
getDirective(): Maybe<GraphQLDirective>;
getArgument(): Maybe<GraphQLArgument>;
Expand Down
2 changes: 1 addition & 1 deletion src/validation/validate.d.ts
Expand Up @@ -43,7 +43,7 @@ export function validateSDL(
documentAST: DocumentNode,
schemaToExtend?: Maybe<GraphQLSchema>,
rules?: ReadonlyArray<SDLValidationRule>,
): Array<GraphQLError>;
): Readonly<GraphQLError>;

/**
* Utility function which asserts a SDL document is valid by throwing an error
Expand Down

0 comments on commit 58b9cd5

Please sign in to comment.