Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
10dc7113
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
10dc7113
编写于
9月 04, 2018
作者:
K
Kitson Kelly
提交者:
Ryan Dahl
9月 05, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Mark APIs at internal and include JSDoc in types
上级
2c0d0084
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
55 addition
and
25 deletion
+55
-25
js/assets.ts
js/assets.ts
+2
-2
js/compiler.ts
js/compiler.ts
+2
-0
js/compiler_test.ts
js/compiler_test.ts
+2
-2
js/errors.ts
js/errors.ts
+2
-0
js/fbs_util.ts
js/fbs_util.ts
+1
-0
js/global-eval.ts
js/global-eval.ts
+9
-5
js/tsconfig.generated.json
js/tsconfig.generated.json
+1
-0
js/util.ts
js/util.ts
+29
-13
js/v8_source_maps.ts
js/v8_source_maps.ts
+4
-0
tests/error_003_typescript.ts.out
tests/error_003_typescript.ts.out
+3
-3
未找到文件。
js/assets.ts
浏览文件 @
10dc7113
...
...
@@ -46,7 +46,7 @@ import textEncodingDts from "/third_party/node_modules/@types/text-encoding/inde
import
typescriptDts
from
"
/third_party/node_modules/typescript/lib/typescript.d.ts!string
"
;
// tslint:enable:max-line-length
//
prettier-ignore
//
@internal
export
const
assetSourceCode
:
{
[
key
:
string
]:
string
}
=
{
// Generated library
"
globals.d.ts
"
:
globalsDts
,
...
...
@@ -85,5 +85,5 @@ export const assetSourceCode: { [key: string]: string } = {
"
fetch-types.d.ts
"
:
fetchTypesDts
,
"
flatbuffers.d.ts
"
:
flatbuffersDts
,
"
text-encoding.d.ts
"
:
textEncodingDts
,
"
typescript.d.ts
"
:
typescriptDts
,
"
typescript.d.ts
"
:
typescriptDts
};
js/compiler.ts
浏览文件 @
10dc7113
...
...
@@ -50,6 +50,7 @@ type OutputCode = string;
/**
* Abstraction of the APIs required from the `os` module so they can be
* easily mocked.
* @internal
*/
export
interface
Os
{
codeCache
:
typeof
os
.
codeCache
;
...
...
@@ -60,6 +61,7 @@ export interface Os {
/**
* Abstraction of the APIs required from the `typescript` module so they can
* be easily mocked.
* @internal
*/
export
interface
Ts
{
createLanguageService
:
typeof
ts
.
createLanguageService
;
...
...
js/compiler_test.ts
浏览文件 @
10dc7113
...
...
@@ -177,7 +177,7 @@ function globalEvalMock(x: string): void {
function
logMock
(...
args
:
any
[]):
void
{
logStack
.
push
(
args
);
}
const
osMock
:
compiler
.
Os
=
{
const
osMock
=
{
codeCache
(
fileName
:
string
,
sourceCode
:
string
,
outputCode
:
string
):
void
{
codeCacheStack
.
push
({
fileName
,
sourceCode
,
outputCode
});
if
(
fileName
in
moduleCache
)
{
...
...
@@ -205,7 +205,7 @@ const osMock: compiler.Os = {
throw
new
Error
(
`os.exit(
${
code
}
)`
);
}
};
const
tsMock
:
compiler
.
Ts
=
{
const
tsMock
=
{
createLanguageService
(
host
:
ts
.
LanguageServiceHost
):
ts
.
LanguageService
{
return
{}
as
ts
.
LanguageService
;
},
...
...
js/errors.ts
浏览文件 @
10dc7113
import
{
deno
as
fbs
}
from
"
gen/msg_generated
"
;
// @internal
export
class
DenoError
<
T
extends
fbs
.
ErrorKind
>
extends
Error
{
constructor
(
readonly
kind
:
T
,
msg
:
string
)
{
super
(
msg
);
...
...
@@ -7,6 +8,7 @@ export class DenoError<T extends fbs.ErrorKind> extends Error {
}
}
// @internal
export
function
maybeThrowError
(
base
:
fbs
.
Base
):
void
{
const
kind
=
base
.
errorKind
();
if
(
kind
!==
fbs
.
ErrorKind
.
NoError
)
{
...
...
js/fbs_util.ts
浏览文件 @
10dc7113
...
...
@@ -4,6 +4,7 @@ import { flatbuffers } from "flatbuffers";
import
{
maybeThrowError
}
from
"
./errors
"
;
import
{
deno
as
fbs
}
from
"
gen/msg_generated
"
;
// @internal
export
function
send
(
builder
:
flatbuffers
.
Builder
,
msgType
:
fbs
.
Any
,
...
...
js/global-eval.ts
浏览文件 @
10dc7113
// If you use the eval function indirectly, by invoking it via a reference
// other than eval, as of ECMAScript 5 it works in the global scope rather than
// the local scope. This means, for instance, that function declarations create
// global functions, and that the code being evaluated doesn't have access to
// local variables within the scope where it's being called.
/**
* If you use the eval function indirectly, by invoking it via a reference
* other than eval, as of ECMAScript 5 it works in the global scope rather than
* the local scope. This means, for instance, that function declarations create
* global functions, and that the code being evaluated doesn't have access to
* local variables within the scope where it's being called.
*
* @internal
*/
export
const
globalEval
=
eval
;
js/tsconfig.generated.json
浏览文件 @
10dc7113
...
...
@@ -8,6 +8,7 @@
"declaration"
:
true
,
"emitDeclarationOnly"
:
true
,
"module"
:
"amd"
,
"removeComments"
:
false
,
"stripInternal"
:
true
},
"files"
:
[
...
...
js/util.ts
浏览文件 @
10dc7113
...
...
@@ -3,11 +3,15 @@ import { TypedArray } from "./types";
let
logDebug
=
false
;
// @internal
export
function
setLogDebug
(
debug
:
boolean
):
void
{
logDebug
=
debug
;
}
// Debug logging for deno. Enable with the --DEBUG command line flag.
/**
* Debug logging for deno. Enable with the `--DEBUG` command line flag.
* @internal
*/
// tslint:disable-next-line:no-any
export
function
log
(...
args
:
any
[]):
void
{
if
(
logDebug
)
{
...
...
@@ -15,41 +19,51 @@ export function log(...args: any[]): void {
}
}
// @internal
export
function
assert
(
cond
:
boolean
,
msg
=
"
assert
"
)
{
if
(
!
cond
)
{
throw
Error
(
msg
);
}
}
// @internal
export
function
typedArrayToArrayBuffer
(
ta
:
TypedArray
):
ArrayBuffer
{
const
ab
=
ta
.
buffer
.
slice
(
ta
.
byteOffset
,
ta
.
byteOffset
+
ta
.
byteLength
);
return
ab
as
ArrayBuffer
;
}
// @internal
export
function
arrayToStr
(
ui8
:
Uint8Array
):
string
{
return
String
.
fromCharCode
(...
ui8
);
}
// A `Resolvable` is a Promise with the `reject` and `resolve` functions
// placed as methods on the promise object itself. It allows you to do:
//
// const p = createResolvable<number>();
// ...
// p.resolve(42);
//
// It'd be prettier to make Resolvable a class that inherits from Promise,
// rather than an interface. This is possible in ES2016, however typescript
// produces broken code when targeting ES5 code.
// See https://github.com/Microsoft/TypeScript/issues/15202
// At the time of writing, the github issue is closed but the problem remains.
/**
* A `Resolvable` is a Promise with the `reject` and `resolve` functions
* placed as methods on the promise object itself. It allows you to do:
*
* const p = createResolvable<number>();
* ...
* p.resolve(42);
*
* It'd be prettier to make Resolvable a class that inherits from Promise,
* rather than an interface. This is possible in ES2016, however typescript
* produces broken code when targeting ES5 code.
* See https://github.com/Microsoft/TypeScript/issues/15202
* At the time of writing, the github issue is closed but the problem remains.
*
* @internal
*/
export
interface
ResolvableMethods
<
T
>
{
resolve
:
(
value
?:
T
|
PromiseLike
<
T
>
)
=>
void
;
// tslint:disable-next-line:no-any
reject
:
(
reason
?:
any
)
=>
void
;
}
// @internal
export
type
Resolvable
<
T
>
=
Promise
<
T
>
&
ResolvableMethods
<
T
>
;
// @internal
export
function
createResolvable
<
T
>
():
Resolvable
<
T
>
{
let
methods
:
ResolvableMethods
<
T
>
;
const
promise
=
new
Promise
<
T
>
((
resolve
,
reject
)
=>
{
...
...
@@ -60,10 +74,12 @@ export function createResolvable<T>(): Resolvable<T> {
return
Object
.
assign
(
promise
,
methods
!
)
as
Resolvable
<
T
>
;
}
// @internal
export
function
notImplemented
():
never
{
throw
new
Error
(
"
Not implemented
"
);
}
// @internal
export
function
unreachable
():
never
{
throw
new
Error
(
"
Code not reachable
"
);
}
js/v8_source_maps.ts
浏览文件 @
10dc7113
...
...
@@ -26,6 +26,7 @@ type GetGeneratedContentsCallback = (fileName: string) => string | RawSourceMap;
let
getGeneratedContents
:
GetGeneratedContentsCallback
;
// @internal
export
function
install
(
options
:
Options
)
{
getGeneratedContents
=
options
.
getGeneratedContents
;
if
(
options
.
installPrepareStackTrace
)
{
...
...
@@ -33,6 +34,7 @@ export function install(options: Options) {
}
}
// @internal
export
function
prepareStackTraceWrapper
(
error
:
Error
,
stack
:
CallSite
[]
...
...
@@ -48,6 +50,7 @@ export function prepareStackTraceWrapper(
}
}
// @internal
export
function
prepareStackTrace
(
error
:
Error
,
stack
:
CallSite
[]):
string
{
const
frames
=
stack
.
map
(
(
frame
:
CallSite
)
=>
`\n at
${
wrapCallSite
(
frame
).
toString
()}
`
...
...
@@ -55,6 +58,7 @@ export function prepareStackTrace(error: Error, stack: CallSite[]): string {
return
error
.
toString
()
+
frames
.
join
(
""
);
}
// @internal
export
function
wrapCallSite
(
frame
:
CallSite
):
CallSite
{
if
(
frame
.
isNative
())
{
return
frame
;
...
...
tests/error_003_typescript.ts.out
浏览文件 @
10dc7113
...
...
@@ -4,7 +4,7 @@
[30;47m [0m [91m~~~~~~[0m
[96m$asset$/globals.d.ts[WILDCARD]
[30;47m[WILDCARD][0m
const console: Console;
[30;47m [0m [96m
~~~~~~~[0m
'console' is declared here.
[WILDCARD]
const console: Console;
[WILDCARD]
~~~~~~~[0m
[WILDCARD]
'console' is declared here.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录