File: moduleResolutionWithSymlinks_referenceTypes.ts

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (54 lines) | stat: -rw-r--r-- 1,716 bytes parent folder | download | duplicates (7)
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
51
52
53
54
// Symlinks are always resolved for type reference directives.
// NOTE: This test would still compile without errors even if they were not,
// because `processTypeReferenceDirective` also checks for textual equivalence of file contents.
// But the `moduleResolutionWithSymlinks_referenceTypes.trace.json` shows the difference.

// @noImplicitReferences: true
// @traceResolution: true
// @fullEmitPaths: true

// @filename: /node_modules/@types/library-a/index.d.ts
// @symlink: /node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts
declare class MyClass { private x: number; }

// @filename: /node_modules/@types/library-b/index.d.ts
/// <reference types="library-a" />

// @filename: /app.ts
/// <reference types="library-a" />
/// <reference types="library-b" />

// @filename: tsconfig.json
{
    "compilerOptions": {
        // If this is its default of node_modules/@types,
        // node_modules/@types/library-a will be looked up be fore node_modules/@types/library-b/node_modules/@types/library-a
        "typeRoots": []
    }
}

/*
# To reproduce in a real project:

echo '/// <reference types="library-a" />' > app.ts
echo '/// <reference types="library-b" />' >> app.ts

mkdir node_modules/@types
cd mode_modules/@types
mkdir library-a
echo 'declare class MyClass { private x: number; }' > library-a/index.d.ts

mkdir library-b
cd library-b
echo '/// <reference types="library-a" />' > index.d.ts

mkdir node_modules
cd node_modules

ln -s ../../library-a ./library-a
# Windows: Open command prompt as administrator and run: `mklink /D library-a ..\..\library-a`

cd ../../.. # back to root

tsc app.ts # Should create `app.js`
*/