Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d37784b
first working version for defining simple custom types
JohannesMeierSE Mar 19, 2025
edd4a32
fixed some other smaller issues
JohannesMeierSE Mar 25, 2025
fa9e3b5
fixed generics, small issues
JohannesMeierSE Apr 4, 2025
9252fe4
no strings for TypeSelectors
JohannesMeierSE Apr 4, 2025
44f5b37
calculate identifiers only from custom properties
JohannesMeierSE Apr 4, 2025
f98b7c7
tests for custom types depending on custom types, no strings for Type…
JohannesMeierSE Apr 4, 2025
bedb16c
test cases for type inference
JohannesMeierSE Apr 6, 2025
f79d0df
fixed bug
JohannesMeierSE Apr 11, 2025
53b3ad3
register as listener and get informed about all existing types, if de…
JohannesMeierSE Apr 11, 2025
8b60ada
conversion and sub-types for custom types
JohannesMeierSE Apr 11, 2025
bdbe76a
test case for validation rules attached to custom type-specific infer…
JohannesMeierSE Apr 11, 2025
796630e
specify names and user representations once for all custom properties…
JohannesMeierSE Apr 11, 2025
0c4659d
test multiple custom types in parallel
JohannesMeierSE Apr 14, 2025
1ced5ca
fixed eslint rule
JohannesMeierSE Apr 15, 2025
74a6f90
support nesting of Properties for custom types
JohannesMeierSE Apr 15, 2025
2571d82
new property to skip type-specific inference rules for types which al…
JohannesMeierSE Apr 16, 2025
7b94761
removed testing stuff, fixed imports
JohannesMeierSE Apr 16, 2025
4e9e31f
more test cases for TypeSelectors with custom types
JohannesMeierSE Apr 16, 2025
d9ea8e1
first improvements according to the review
JohannesMeierSE Jul 4, 2025
98ec8e9
more improvements
JohannesMeierSE Jul 5, 2025
e50d304
improved comments according to the review
JohannesMeierSE Jul 8, 2025
1f63167
properties of custom types are readonly now, default implementation f…
JohannesMeierSE Jul 9, 2025
7003a61
added missing implementation (which will be improved in future PRs)
JohannesMeierSE Jul 9, 2025
7a98ce1
unified initialization design for classes, functions and custom types
JohannesMeierSE Jul 9, 2025
67de361
check typeName for uniqueness
JohannesMeierSE Jul 9, 2025
e551485
wrote some documentation for custom types
JohannesMeierSE Jul 9, 2025
6567a1e
fixes according to the review
JohannesMeierSE Jul 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/kinds/custom-types.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ In the example above, calling `matrix2x3.properties.width` is supported by auto-
### Uniqueness

Typir ensures uniqueness for custom types.
Two custom types are unique, if their identifiers are the same (this counts for any type, not only for custom types).
Two custom types are identical, if their identifiers are the same (this counts for any type, not only for custom types).
The default implementation calculates the identifier by concatenating the values of all properties.

### Circular dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { assertTypirType } from '../../../src/utils/utils.js';
* The custom type called "Matrix" represents a two-dimensional array of primitive types.
* Known from mathematics, the "width" represents the number of columns and the "height" the number of row of a matrix.
*
* This TypeScript type specifies the properties of the the Typir types which represent "matrices".
* This TypeScript type specifies the properties of the Typir types which represent "matrices".
*/
export type MatrixType = { // "interface" instead of "type" does not work!
baseType: PrimitiveType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { createTypirServicesForTesting, expectToBeType } from '../../../src/util
* The custom type called "RestrictedInteger" represents a primitive integer type with an upper bound,
* i.e. it looks like usual integers, but integer values/literals higher than the upper bound cannot be assigned to the restricted integer.
*
* This TypeScript type specifies the properties of the the Typir types which represent "restricted integers".
* This TypeScript type specifies the properties of the Typir types which represent "restricted integers".
*/
export type RestrictedInteger = {
upperBound: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TestLanguageNode } from '../../../src/test/predefined-language-nodes.js
import { TypirServices } from '../../../src/typir.js';
import { createTypirServicesForTesting, expectTypirTypes } from '../../../src/utils/test-utils.js';

Comment thread
insafuhrmann marked this conversation as resolved.
// These test cases test, that it is possible to work with two different kinds of custom types independent from each other in the same Typir instance,
// These test cases test that it is possible to work with two different kinds of custom types independent from each other in the same Typir instance,
// even when these custom types/kinds have the same properties!

export type MyCustomType1 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { TestLanguageNode } from '../../../src/test/predefined-language-nodes.js
import { TypirServices } from '../../../src/typir.js';
import { createTypirServicesForTesting } from '../../../src/utils/test-utils.js';

// These test cases test, that nesting of properties for custom types is possible (including recursion).
// These test cases test that nesting of properties for custom types is possible (including recursion).

export type NestedProperty = {
myBool: boolean;
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('Check that nested properties for custom types work', () => {
const customKind = new CustomKind<Properties, TestLanguageNode>(typir, {
name: 'MyCustom',
/** Compared with the test case above, this calculation creates the same identifiers, since it does not take the deeper nesting into account.
* For these independent test cases, this is now problem.
* For these independent test cases, this is no problem.
* But if both kinds are used together in the same Typir instance, the calculation of type identifiers need to be different for both kinds in order to produce unique identifiers.
*/
calculateTypeIdentifier: properties => `mycustom-${properties.nested.deeper.myBool}-${typir.infrastructure.TypeResolver.resolve(properties.nested.deeper.myType).getIdentifier()}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/typir/test/kinds/custom/custom-selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TestExpressionNode, TestLanguageNode } from '../../../src/test/predefin
import { TypirServices } from '../../../src/typir.js';
import { createTypirServicesForTesting } from '../../../src/utils/test-utils.js';

// These test cases test, that all possible TypeSelectors work for custom types.
// These test cases test that all possible TypeSelectors work for custom types.

export type MyCustomProperties = {
dependsOnType?: CustomType<MyCustomProperties, TestLanguageNode>;
Expand Down