2

I have successfully installed a typescript sandbox (this one) and I have managed to create a simple service and a few components.

I would like to access this set of helper functions. It seems to be part of the typescript core. However, I am not sure how I could get access to that core.

tried import {ArrayUtilities} from 'core' and a few other random tries.

2 Answers 2

2

unfortunatly, you can't do that. Typescript core is compiler features, they are not done in order to use them in your typescript code but done to perform compiling over existing ts files.

Here is the updated link for the ressource you wanted to integrate (source is updated by microsoft/google): https://github.com/Microsoft/TypeScript/blob/master/src/compiler/core.ts

Here is more information about the language architecture : https://github.com/Microsoft/TypeScript/wiki/Architectural-Overview

use instead javascript arrays function for example : http://www.w3schools.com/jsref/jsref_obj_array.asp

Sign up to request clarification or add additional context in comments.

4 Comments

ok, thanks. how would you proceed then? I need some basic functions to manipulate [] and in this case distinct. It feels odd having to rewrite everything from scratch.
ok.why not to use javascript arrays methods provided natively : w3schools.com/js/js_array_methods.asp . Do you find the methods you need?
distinct (unique) is missing but I can code it up. Just surprised that the list of helpers in typescript is so thin. Tnx for your help.
in this case, you can have an Array.filter( distinc clauses) that will return an array it's really a simple solution. w3schools.com/jsref/jsref_filter.asp . not many helpers in ts, but a great simple langage. Learning curve is pretty flat & easy. have fun
1

I would like to access this set of helper functions. It seems to be part of the typescript core

The are a part of the TypeScript compiler (also that link is really really old. The latest source is here https://github.com/Microsoft/TypeScript/)

You cannot use the compiler code base implicitly. i.e. it doesn't magically become available to your code. TypeScript has no runtime.

You can however use the typecript compiler expilicity by taking a depenency on the typescript module. (npm install typescript and then import ts = require('typescript'). However it feels like a big overkill for just a few array functions. You would be better off copy / pasting in your codebase 🌹

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.