UNPKG

typir

Version:

General purpose type checking library

42 lines 1.71 kB
/****************************************************************************** * Copyright 2024 TypeFox GmbH * This program and the accompanying materials are made available under the * terms of the MIT License, which is available in the project root. ******************************************************************************/ import { isType, Type } from '../../graph/type-node.js'; import { TypeEqualityProblem } from '../../services/equality.js'; import { checkValueForConflict, createKindConflict } from '../../utils/utils-type-comparison.js'; import { isPrimitiveKind } from './primitive-kind.js'; export class PrimitiveType extends Type { constructor(kind, identifier, typeDetails) { super(identifier, typeDetails); this.kind = kind; this.defineTheInitializationProcessOfThisType({}); // no preconditions } getName() { return this.getIdentifier(); } getUserRepresentation() { return this.getIdentifier(); } analyzeTypeEqualityProblems(otherType) { if (isPrimitiveType(otherType)) { return checkValueForConflict(this.getIdentifier(), otherType.getIdentifier(), 'name'); } else { return [{ $problem: TypeEqualityProblem, type1: this, type2: otherType, subProblems: [createKindConflict(otherType, this)], }]; } } analyzeSubTypeProblems(subType, superType) { return subType.analyzeTypeEqualityProblems(superType); } } export function isPrimitiveType(type) { return isType(type) && isPrimitiveKind(type.kind); } //# sourceMappingURL=primitive-type.js.map