Intrinsics are the primitive building block data types common across source and target platforms:

We can define the intrinsic data types for a given target platform by aliasing to one of the above types in stub APIs.

Sempiler will treat each of these type definitions as the intrinsic role they represent when type checking and validating input.

OOP

In many programming languages these intrinsic data types are autoboxed objects rather than just raw primitives.

As such, we may want to model instance methods on an intrinsic data type. How we achieve this depends on the source language we are using.

Updated API

To model OOP intrinsics in TypeScript stub APIs we can use the following decorators:

Decorator Usage Notes
@boolean Permit instances of this type to type check as a boolean  
@number Permit instances of this type to type check as numeric  
@string Permit instances of this type to type check as a string  

These decorators give us the ability to concisely represent intrinsic types that have instance properties, like in Swift:

Legacy API

Older versions of Sempiler model OOP intrinsics differently. Take this example in TypeScript for modelling a Swift Int8:

Using the __internal$$ prefix adds unfortunate noise, but Sempiler will detect this prefix and remove it internally.

NOTE __internal$$Foo will be treated simply as Foo, hence a declaration for Foo must exist in scope.

User Defined

You can now follow the approach described above to define your own intrinsic types.

This is useful if said types are missing from the symbols available from the repository (be sure to submit them if so!).

Platform Specific

The intrinsics available to your code depend on the symbols available on the target platform.