Skip to content

Commit ab10b86

Browse files
committed
Almost working?
1 parent 19fe86a commit ab10b86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+377
-273
lines changed

Jakefile.js

+140-114
Large diffs are not rendered by default.

scripts/buildProtocol.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class DeclarationsWalker {
4646
if (!s) {
4747
return;
4848
}
49-
if (s.name === "Array") {
49+
if (s.name === "Array" || s.name === "ReadOnlyArray") {
5050
// we should process type argument instead
5151
return this.processType((<any>type).typeArguments[0]);
5252
}
@@ -55,7 +55,7 @@ class DeclarationsWalker {
5555
if (declarations) {
5656
for (const decl of declarations) {
5757
const sourceFile = decl.getSourceFile();
58-
if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") {
58+
if (sourceFile === this.protocolFile || /lib\.(.*)\.d.ts/.test(path.basename(sourceFile.fileName))) {
5959
return;
6060
}
6161
if (decl.kind === ts.SyntaxKind.EnumDeclaration && !isStringEnum(decl as ts.EnumDeclaration)) {
@@ -131,13 +131,20 @@ function writeProtocolFile(outputFile: string, protocolTs: string, typeScriptSer
131131
const program = ts.createProgram([protocolTs, typeScriptServicesDts], options);
132132

133133
let protocolDts: string | undefined;
134-
program.emit(program.getSourceFile(protocolTs), (file, content) => {
134+
const emitResult = program.emit(program.getSourceFile(protocolTs), (file, content) => {
135135
if (endsWith(file, ".d.ts")) {
136136
protocolDts = content;
137137
}
138138
});
139+
139140
if (protocolDts === undefined) {
140-
throw new Error(`Declaration file for protocol.ts is not generated`)
141+
const diagHost: ts.FormatDiagnosticsHost = {
142+
getCanonicalFileName: function (f) { return f; },
143+
getCurrentDirectory: function() { return '.'; },
144+
getNewLine: function() { return "\r\n"; }
145+
}
146+
const diags = emitResult.diagnostics.map(d => ts.formatDiagnostic(d, diagHost)).join("\r\n");
147+
throw new Error(`Declaration file for protocol.ts is not generated:\r\n${diags}`);
141148
}
142149
return protocolDts;
143150
}

src/compiler/tsconfig.json

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"files": [
77
"binder.ts",
88
"symbolWalker.ts",
9-
"moduleNameResolver.ts",
109
"checker.ts",
1110
"factory.ts",
1211
"visitor.ts",

src/harness/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
{ "path": "../parser" },
1616
{ "path": "../compiler" },
1717
{ "path": "../services" },
18+
{ "path": "../jsTyping" },
1819
{ "path": "../server" },
1920
{ "path": "../typingsInstallerCore" }
2021
],
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/jsTyping/tsconfig.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"extends": "../tsconfig-base",
3+
"compilerOptions": {
4+
"outFile": "../../built/local/jsTyping.js",
5+
"types": [
6+
"node"
7+
],
8+
"lib": [
9+
"es6",
10+
"scripthost"
11+
]
12+
},
13+
"references": [
14+
{ "path": "../core" },
15+
{ "path": "../parser" }
16+
],
17+
"files": [
18+
"shared.ts",
19+
"types.ts",
20+
"jsTyping.ts",
21+
"semver.ts"
22+
]
23+
}

src/jsTyping/types.ts

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
declare namespace ts.server {
2+
export type ActionSet = "action::set";
3+
export type ActionInvalidate = "action::invalidate";
4+
export type ActionPackageInstalled = "action::packageInstalled";
5+
export type EventTypesRegistry = "event::typesRegistry";
6+
export type EventBeginInstallTypes = "event::beginInstallTypes";
7+
export type EventEndInstallTypes = "event::endInstallTypes";
8+
export type EventInitializationFailed = "event::initializationFailed";
9+
10+
export interface SortedReadonlyArray<T> extends ReadonlyArray<T> {
11+
" __sortedArrayBrand": any;
12+
}
13+
14+
export interface TypingInstallerResponse {
15+
readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed;
16+
}
17+
18+
export interface TypingInstallerRequestWithProjectName {
19+
readonly projectName: string;
20+
}
21+
22+
/* @internal */
23+
export type TypingInstallerRequestUnion = DiscoverTypings | CloseProject | TypesRegistryRequest | InstallPackageRequest;
24+
25+
export interface DiscoverTypings extends TypingInstallerRequestWithProjectName {
26+
readonly fileNames: string[];
27+
readonly projectRootPath: Path;
28+
readonly compilerOptions: CompilerOptions;
29+
readonly typeAcquisition: TypeAcquisition;
30+
readonly unresolvedImports: SortedReadonlyArray<string>;
31+
readonly cachePath?: string;
32+
readonly kind: "discover";
33+
}
34+
35+
export interface CloseProject extends TypingInstallerRequestWithProjectName {
36+
readonly kind: "closeProject";
37+
}
38+
39+
export interface TypesRegistryRequest {
40+
readonly kind: "typesRegistry";
41+
}
42+
43+
export interface InstallPackageRequest extends TypingInstallerRequestWithProjectName {
44+
readonly kind: "installPackage";
45+
readonly fileName: Path;
46+
readonly packageName: string;
47+
readonly projectRootPath: Path;
48+
}
49+
50+
/* @internal */
51+
export interface TypesRegistryResponse extends TypingInstallerResponse {
52+
readonly kind: EventTypesRegistry;
53+
readonly typesRegistry: MapLike<MapLike<string>>;
54+
}
55+
56+
export interface PackageInstalledResponse extends ProjectResponse {
57+
readonly kind: ActionPackageInstalled;
58+
readonly success: boolean;
59+
readonly message: string;
60+
}
61+
62+
export interface InitializationFailedResponse extends TypingInstallerResponse {
63+
readonly kind: EventInitializationFailed;
64+
readonly message: string;
65+
}
66+
67+
export interface ProjectResponse extends TypingInstallerResponse {
68+
readonly projectName: string;
69+
}
70+
71+
export interface InvalidateCachedTypings extends ProjectResponse {
72+
readonly kind: ActionInvalidate;
73+
}
74+
75+
export interface InstallTypes extends ProjectResponse {
76+
readonly kind: EventBeginInstallTypes | EventEndInstallTypes;
77+
readonly eventId: number;
78+
readonly typingsInstallerVersion: string;
79+
readonly packagesToInstall: ReadonlyArray<string>;
80+
}
81+
82+
export interface BeginInstallTypes extends InstallTypes {
83+
readonly kind: EventBeginInstallTypes;
84+
}
85+
86+
export interface EndInstallTypes extends InstallTypes {
87+
readonly kind: EventEndInstallTypes;
88+
readonly installSuccess: boolean;
89+
}
90+
91+
/* @internal */
92+
export interface InstallTypingHost extends JsTyping.TypingResolutionHost {
93+
useCaseSensitiveFileNames: boolean;
94+
writeFile(path: string, content: string): void;
95+
createDirectory(path: string): void;
96+
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher;
97+
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
98+
}
99+
100+
export interface SetTypings extends ProjectResponse {
101+
readonly typeAcquisition: TypeAcquisition;
102+
readonly compilerOptions: CompilerOptions;
103+
readonly typings: string[];
104+
readonly unresolvedImports: SortedReadonlyArray<string>;
105+
readonly kind: ActionSet;
106+
}
107+
108+
/* @internal */
109+
export type TypingInstallerResponseUnion = SetTypings | InvalidateCachedTypings | TypesRegistryResponse | PackageInstalledResponse | InstallTypes | InitializationFailedResponse;
110+
}
File renamed without changes.

src/parser/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"scanner.ts",
1111
"utilities.ts",
1212
"parser.ts",
13-
"commandLineParser.ts"
13+
"commandLineParser.ts",
14+
"moduleNameResolver.ts"
1415
],
1516
"references": [
1617
{ "path": "../core" }

src/server/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
{ "path": "../core" },
1313
{ "path": "../parser" },
1414
{ "path": "../compiler" },
15+
{ "path": "../jsTyping" },
1516
{ "path": "../services" }
1617
],
1718
"files": [
1819
"types.ts",
19-
"shared.ts",
2020
"utilities.ts",
2121
"protocol.ts",
2222
"scriptInfo.ts",

src/server/types.ts

-108
Original file line numberDiff line numberDiff line change
@@ -17,112 +17,4 @@ declare namespace ts.server {
1717
trace?(s: string): void;
1818
require?(initialPath: string, moduleName: string): RequireResult;
1919
}
20-
21-
export interface SortedReadonlyArray<T> extends ReadonlyArray<T> {
22-
" __sortedArrayBrand": any;
23-
}
24-
25-
export interface TypingInstallerRequestWithProjectName {
26-
readonly projectName: string;
27-
}
28-
29-
/* @internal */
30-
export type TypingInstallerRequestUnion = DiscoverTypings | CloseProject | TypesRegistryRequest | InstallPackageRequest;
31-
32-
export interface DiscoverTypings extends TypingInstallerRequestWithProjectName {
33-
readonly fileNames: string[];
34-
readonly projectRootPath: Path;
35-
readonly compilerOptions: CompilerOptions;
36-
readonly typeAcquisition: TypeAcquisition;
37-
readonly unresolvedImports: SortedReadonlyArray<string>;
38-
readonly cachePath?: string;
39-
readonly kind: "discover";
40-
}
41-
42-
export interface CloseProject extends TypingInstallerRequestWithProjectName {
43-
readonly kind: "closeProject";
44-
}
45-
46-
export interface TypesRegistryRequest {
47-
readonly kind: "typesRegistry";
48-
}
49-
50-
export interface InstallPackageRequest extends TypingInstallerRequestWithProjectName {
51-
readonly kind: "installPackage";
52-
readonly fileName: Path;
53-
readonly packageName: string;
54-
readonly projectRootPath: Path;
55-
}
56-
57-
export type ActionSet = "action::set";
58-
export type ActionInvalidate = "action::invalidate";
59-
export type ActionPackageInstalled = "action::packageInstalled";
60-
export type EventTypesRegistry = "event::typesRegistry";
61-
export type EventBeginInstallTypes = "event::beginInstallTypes";
62-
export type EventEndInstallTypes = "event::endInstallTypes";
63-
export type EventInitializationFailed = "event::initializationFailed";
64-
65-
export interface TypingInstallerResponse {
66-
readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed;
67-
}
68-
/* @internal */
69-
export type TypingInstallerResponseUnion = SetTypings | InvalidateCachedTypings | TypesRegistryResponse | PackageInstalledResponse | InstallTypes | InitializationFailedResponse;
70-
71-
/* @internal */
72-
export interface TypesRegistryResponse extends TypingInstallerResponse {
73-
readonly kind: EventTypesRegistry;
74-
readonly typesRegistry: MapLike<MapLike<string>>;
75-
}
76-
77-
export interface PackageInstalledResponse extends ProjectResponse {
78-
readonly kind: ActionPackageInstalled;
79-
readonly success: boolean;
80-
readonly message: string;
81-
}
82-
83-
export interface InitializationFailedResponse extends TypingInstallerResponse {
84-
readonly kind: EventInitializationFailed;
85-
readonly message: string;
86-
}
87-
88-
export interface ProjectResponse extends TypingInstallerResponse {
89-
readonly projectName: string;
90-
}
91-
92-
export interface SetTypings extends ProjectResponse {
93-
readonly typeAcquisition: TypeAcquisition;
94-
readonly compilerOptions: CompilerOptions;
95-
readonly typings: string[];
96-
readonly unresolvedImports: SortedReadonlyArray<string>;
97-
readonly kind: ActionSet;
98-
}
99-
100-
export interface InvalidateCachedTypings extends ProjectResponse {
101-
readonly kind: ActionInvalidate;
102-
}
103-
104-
export interface InstallTypes extends ProjectResponse {
105-
readonly kind: EventBeginInstallTypes | EventEndInstallTypes;
106-
readonly eventId: number;
107-
readonly typingsInstallerVersion: string;
108-
readonly packagesToInstall: ReadonlyArray<string>;
109-
}
110-
111-
export interface BeginInstallTypes extends InstallTypes {
112-
readonly kind: EventBeginInstallTypes;
113-
}
114-
115-
export interface EndInstallTypes extends InstallTypes {
116-
readonly kind: EventEndInstallTypes;
117-
readonly installSuccess: boolean;
118-
}
119-
120-
/* @internal */
121-
export interface InstallTypingHost extends JsTyping.TypingResolutionHost {
122-
useCaseSensitiveFileNames: boolean;
123-
writeFile(path: string, content: string): void;
124-
createDirectory(path: string): void;
125-
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher;
126-
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
127-
}
12820
}

src/services/tsconfig.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"extends": "../tsconfig-base",
33
"compilerOptions": {
4-
"outFile": "../../built/local/typescriptServices.js"
4+
"outFile": "../../built/local/services.js"
55
},
66
"references": [
77
{ "path": "../core" },
88
{ "path": "../parser" },
9-
{ "path": "../compiler" }
9+
{ "path": "../compiler" },
10+
{ "path": "../jsTyping" },
1011
],
1112
"files": [
1213
"types.ts",
@@ -21,8 +22,6 @@
2122
"getEditsForFileRename.ts",
2223
"goToDefinition.ts",
2324
"jsDoc.ts",
24-
"semver.ts",
25-
"jsTyping.ts",
2625
"navigateTo.ts",
2726
"navigationBar.ts",
2827
"organizeImports.ts",

0 commit comments

Comments
 (0)