简体   繁体   English

打字稿-导入核心功能

[英]typescript - import core functions

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. 尝试import {ArrayUtilities} from 'core'以及其他一些随机尝试。

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. Typescript核心是编译器功能,并不是为了在您的Typescript代码中使用它们而进行的,而是为了对现有ts文件执行编译。

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 这是您要集成的资源的更新链接(源由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 这是有关语言体系结构的更多信息: https : //github.com/Microsoft/TypeScript/wiki/Architectural-Overview

use instead javascript arrays function for example : http://www.w3schools.com/jsref/jsref_obj_array.asp 请改用javascript数组函数,例如: http : //www.w3schools.com/jsref/jsref_obj_array.asp

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/ ) 是TypeScript编译器的一部分(该链接真的很旧。最新资源在这里https://github.com/Microsoft/TypeScript/

You cannot use the compiler code base implicitly . 您不能隐式使用编译器代码库。 ie it doesn't magically become available to your code. 即它不会神奇地变为可用于您的代码。 TypeScript has no runtime. TypeScript没有运行时。

You can however use the typecript compiler expilicity by taking a depenency on the typescript module. 但是,您可以使用typecript编译 expilicity通过采取depenency上typescript模块。 ( 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 🌹 npm install typescript ,然后再import ts = require('typescript') 。但是,对于一些数组函数来说,这似乎是一个过大的杀伤力。您最好在代码库中复制/粘贴🌹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM