-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
50 lines (49 loc) · 2.09 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Includes (inlines) content of the specified file into the source file.
* Call of this function will be replaced with the file's content by
* the TypeScript transformer. It will also remove import of this module,
* so you don't need it in run-time.
*
* If the *filename* doesn't exist or couldn't be read, the transformer throws
* an error in the transpilation (build) phase.
*
* NOTE: This function can be used only as a call expression. Any other use
* results in a runtime error!
*
* @example
* const words = $INLINE_FILE('../data/words.txt').trim().split(' ')
* // will be transformed to:
* const words = "lorem ipsum dolor\n".trim().split(" ");
* // where "lorem ... \n" is content of the *filename*
*
* @param filename The path of the file to include (relative to the caller file).
* @return A content of the *filename*.
*/
export declare function $INLINE_FILE (filename: string): string
/**
* Includes (inlines) the specified JSON file as an literal object.
* Call of this function will be replaced with the foregoing by the TypeScript
* transformer. It will also remove import of this module, so you don't need
* it in run-time.
*
* If call of this function is directly preceded by an object destructuring
* assignment, then the object literal will be filtered to contain only the
* assigned properties (i.e. only these will be inlined). However, this works
* only for the top level; filtering of nested properties is not supported.
*
* If the *filename* doesn't exist or couldn't be read, the transformer throws
* an error in the transpilation (build) phase.
*
* NOTE: This function can be used only as a call expression. Any other use
* results in a runtime error!
*
* @example
* const { name, version } = $INLINE_JSON('../package.json')
* // will be transformed to:
* const { name, version } = { "name": "flynn", "version": "1.0.0" };
*
* @param filename The path of the JSON file to include (relative to the caller file).
* @return A parsed JSON object.
* @template R is the return type.
*/
export declare function $INLINE_JSON <R = any> (filename: string): R