Fix all TypeScript type errors
This commit is contained in:
parent
9d28d47d6f
commit
fe4cc61819
2 changed files with 12 additions and 11 deletions
|
@ -1,10 +1,12 @@
|
|||
import {
|
||||
EnumDeclaration,
|
||||
EnumDeclarationStructElement,
|
||||
Expression,
|
||||
LetDeclaration,
|
||||
Pattern,
|
||||
Scope,
|
||||
SourceFile,
|
||||
StructDeclaration,
|
||||
Symkind,
|
||||
Syntax,
|
||||
SyntaxKind,
|
||||
|
@ -21,15 +23,10 @@ import {
|
|||
KindMismatchDiagnostic,
|
||||
} from "./diagnostics";
|
||||
import { assert, isEmpty, MultiMap } from "./util";
|
||||
import { LabeledDirectedHashGraph, LabeledGraph, strongconnect } from "yagl"
|
||||
import { Analyser } from "./analysis";
|
||||
|
||||
const MAX_TYPE_ERROR_COUNT = 5;
|
||||
|
||||
type NodeWithBindings = SourceFile | LetDeclaration;
|
||||
|
||||
type ReferenceGraph = LabeledGraph<NodeWithBindings, boolean>;
|
||||
|
||||
export enum TypeKind {
|
||||
Arrow,
|
||||
Var,
|
||||
|
@ -280,7 +277,7 @@ export class TRecord extends TypeBase {
|
|||
public readonly kind = TypeKind.Record;
|
||||
|
||||
public constructor(
|
||||
public decl: Syntax,
|
||||
public decl: StructDeclaration | EnumDeclarationStructElement,
|
||||
public kindArgs: TVar[],
|
||||
public fields: Map<string, Type>,
|
||||
public node: Syntax | null = null,
|
||||
|
@ -380,7 +377,7 @@ export class TVariant extends TypeBase {
|
|||
public readonly kind = TypeKind.Variant;
|
||||
|
||||
public constructor(
|
||||
public decl: Syntax,
|
||||
public decl: EnumDeclaration,
|
||||
public kindArgs: Type[],
|
||||
public elementTypes: Type[],
|
||||
public node: Syntax | null = null,
|
||||
|
@ -710,7 +707,7 @@ class Forall extends SchemeBase {
|
|||
|
||||
}
|
||||
|
||||
type Scheme
|
||||
export type Scheme
|
||||
= Forall
|
||||
|
||||
export class TypeEnv {
|
||||
|
@ -1298,7 +1295,7 @@ export class Checker {
|
|||
return this.createTypeVar();
|
||||
}
|
||||
assert(decl.kind === SyntaxKind.StructDeclaration || decl.kind === SyntaxKind.EnumDeclarationStructElement);
|
||||
const scheme = decl.scheme;
|
||||
const scheme = decl.scheme!;
|
||||
const declType = this.instantiate(scheme, node);
|
||||
const kindArgs = [];
|
||||
const varExps = decl.kind === SyntaxKind.StructDeclaration
|
||||
|
@ -1435,7 +1432,7 @@ export class Checker {
|
|||
|
||||
}
|
||||
|
||||
public inferBindings(pattern: Pattern, typeVars: TVar[], constraints: Constraint[]): Type {
|
||||
public inferBindings(pattern: Pattern, typeVars: Iterable<TVar>, constraints: Iterable<Constraint>): Type {
|
||||
|
||||
switch (pattern.kind) {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { JSONObject, JSONValue, MultiMap } from "./util";
|
||||
import type { InferContext, Type, TypeEnv } from "./checker"
|
||||
import type { InferContext, Scheme, Type, TypeEnv } from "./checker"
|
||||
|
||||
export type TextSpan = [number, number];
|
||||
|
||||
|
@ -1713,6 +1713,8 @@ export class EnumDeclarationStructElement extends SyntaxBase {
|
|||
|
||||
public readonly kind = SyntaxKind.EnumDeclarationStructElement;
|
||||
|
||||
public scheme?: Scheme;
|
||||
|
||||
public constructor(
|
||||
public name: IdentifierAlt,
|
||||
public blockStart: BlockStart,
|
||||
|
@ -1821,6 +1823,7 @@ export class StructDeclaration extends SyntaxBase {
|
|||
public readonly kind = SyntaxKind.StructDeclaration;
|
||||
|
||||
public typeEnv?: TypeEnv;
|
||||
public scheme?: Scheme;
|
||||
|
||||
public constructor(
|
||||
public pubKeyword: PubKeyword | null,
|
||||
|
@ -1948,6 +1951,7 @@ export class TypeDeclaration extends SyntaxBase {
|
|||
|
||||
public readonly kind = SyntaxKind.TypeDeclaration;
|
||||
|
||||
public scheme?: Scheme;
|
||||
public typeEnv?: TypeEnv;
|
||||
|
||||
public constructor(
|
||||
|
|
Loading…
Reference in a new issue