Constrained primitive types
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 12/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- backend
Research direction
This is a design discussion about a general mechanism for constrained primitive types, not a bounded change. Read the custom type API example at packages/typir/test/kinds/custom/custom-example-restricted.test.ts to see how restricted types are built today. The issue has no comments and no assignee, so any work would need the maintainers to agree on the API first. Done would mean a proposal agreed on in the thread, not a code patch.
Written by the indexing model from the issue text.
Description
Examples are:
- strings with restricted length, regular expressions (type inference for concatenation of restricted strings)
- min/max / ranges for numbers (type inference for addition of ranges:
<range> + <range>) - physical units
- arrays with fixed length
Requirements:
- Assignability/sub-type rules depend on the current DSL!
- Provide general mechanism / API for "arbitrary" constrainted primitives
- Maybe provide some defaults?
- Maybe support additional properties (not generics #26!) for types, which are not relevant for assignability/validation, but for code generation, e.g. UTF-8 encoding for strings?
- Default behaviour of new parameters is empty, add more behaviour if required by explicit API calls for e.g. assignability, inference
- Maybe these issues target not only primitive types, but any kinds of types?
Ideas for solution
- It is possible to realize constrained primitive types with the custom type API, see:
packages/typir/test/kinds/custom/custom-example-restricted.test.ts, but maybe there is an easier way.
- Dominant language
- TypeScript
- Stars
- 52
- Forks
- 5
- Avg merge
- 1h 31m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TypeFox/typir
-
Difficulty 3/5 Half a day Newbie friendliness 22/100
-
Infrastructure
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Infrastructure
Difficulty 5/5 Over a week Newbie friendliness 12/100
-
Infrastructure
Difficulty 5/5 Over a week Newbie friendliness 12/100
-
Predefined Types
Difficulty 5/5 Over a week Newbie friendliness 12/100
Similar issues
-
Autocomplete still accepts an option after becoming disabledPossibly taken @Xapollon430 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
reduxjs/react-redux#2416 · 1 comment ·