Almost working?

This commit is contained in:
Ryan Cavanaugh
2018-06-10 19:28:38 -07:00
parent 19fe86a8c1
commit ab10b86205
74 changed files with 377 additions and 273 deletions

View File

@@ -6,7 +6,6 @@
"files": [
"binder.ts",
"symbolWalker.ts",
"moduleNameResolver.ts",
"checker.ts",
"factory.ts",
"visitor.ts",

View File

@@ -15,6 +15,7 @@
{ "path": "../parser" },
{ "path": "../compiler" },
{ "path": "../services" },
{ "path": "../jsTyping" },
{ "path": "../server" },
{ "path": "../typingsInstallerCore" }
],

View File

@@ -0,0 +1,23 @@
{
"extends": "../tsconfig-base",
"compilerOptions": {
"outFile": "../../built/local/jsTyping.js",
"types": [
"node"
],
"lib": [
"es6",
"scripthost"
]
},
"references": [
{ "path": "../core" },
{ "path": "../parser" }
],
"files": [
"shared.ts",
"types.ts",
"jsTyping.ts",
"semver.ts"
]
}

110
src/jsTyping/types.ts Normal file
View File

@@ -0,0 +1,110 @@
declare namespace ts.server {
export type ActionSet = "action::set";
export type ActionInvalidate = "action::invalidate";
export type ActionPackageInstalled = "action::packageInstalled";
export type EventTypesRegistry = "event::typesRegistry";
export type EventBeginInstallTypes = "event::beginInstallTypes";
export type EventEndInstallTypes = "event::endInstallTypes";
export type EventInitializationFailed = "event::initializationFailed";
export interface SortedReadonlyArray<T> extends ReadonlyArray<T> {
" __sortedArrayBrand": any;
}
export interface TypingInstallerResponse {
readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed;
}
export interface TypingInstallerRequestWithProjectName {
readonly projectName: string;
}
/* @internal */
export type TypingInstallerRequestUnion = DiscoverTypings | CloseProject | TypesRegistryRequest | InstallPackageRequest;
export interface DiscoverTypings extends TypingInstallerRequestWithProjectName {
readonly fileNames: string[];
readonly projectRootPath: Path;
readonly compilerOptions: CompilerOptions;
readonly typeAcquisition: TypeAcquisition;
readonly unresolvedImports: SortedReadonlyArray<string>;
readonly cachePath?: string;
readonly kind: "discover";
}
export interface CloseProject extends TypingInstallerRequestWithProjectName {
readonly kind: "closeProject";
}
export interface TypesRegistryRequest {
readonly kind: "typesRegistry";
}
export interface InstallPackageRequest extends TypingInstallerRequestWithProjectName {
readonly kind: "installPackage";
readonly fileName: Path;
readonly packageName: string;
readonly projectRootPath: Path;
}
/* @internal */
export interface TypesRegistryResponse extends TypingInstallerResponse {
readonly kind: EventTypesRegistry;
readonly typesRegistry: MapLike<MapLike<string>>;
}
export interface PackageInstalledResponse extends ProjectResponse {
readonly kind: ActionPackageInstalled;
readonly success: boolean;
readonly message: string;
}
export interface InitializationFailedResponse extends TypingInstallerResponse {
readonly kind: EventInitializationFailed;
readonly message: string;
}
export interface ProjectResponse extends TypingInstallerResponse {
readonly projectName: string;
}
export interface InvalidateCachedTypings extends ProjectResponse {
readonly kind: ActionInvalidate;
}
export interface InstallTypes extends ProjectResponse {
readonly kind: EventBeginInstallTypes | EventEndInstallTypes;
readonly eventId: number;
readonly typingsInstallerVersion: string;
readonly packagesToInstall: ReadonlyArray<string>;
}
export interface BeginInstallTypes extends InstallTypes {
readonly kind: EventBeginInstallTypes;
}
export interface EndInstallTypes extends InstallTypes {
readonly kind: EventEndInstallTypes;
readonly installSuccess: boolean;
}
/* @internal */
export interface InstallTypingHost extends JsTyping.TypingResolutionHost {
useCaseSensitiveFileNames: boolean;
writeFile(path: string, content: string): void;
createDirectory(path: string): void;
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
}
export interface SetTypings extends ProjectResponse {
readonly typeAcquisition: TypeAcquisition;
readonly compilerOptions: CompilerOptions;
readonly typings: string[];
readonly unresolvedImports: SortedReadonlyArray<string>;
readonly kind: ActionSet;
}
/* @internal */
export type TypingInstallerResponseUnion = SetTypings | InvalidateCachedTypings | TypesRegistryResponse | PackageInstalledResponse | InstallTypes | InitializationFailedResponse;
}

View File

@@ -10,7 +10,8 @@
"scanner.ts",
"utilities.ts",
"parser.ts",
"commandLineParser.ts"
"commandLineParser.ts",
"moduleNameResolver.ts"
],
"references": [
{ "path": "../core" }

View File

@@ -12,11 +12,11 @@
{ "path": "../core" },
{ "path": "../parser" },
{ "path": "../compiler" },
{ "path": "../jsTyping" },
{ "path": "../services" }
],
"files": [
"types.ts",
"shared.ts",
"utilities.ts",
"protocol.ts",
"scriptInfo.ts",

View File

@@ -17,112 +17,4 @@ declare namespace ts.server {
trace?(s: string): void;
require?(initialPath: string, moduleName: string): RequireResult;
}
export interface SortedReadonlyArray<T> extends ReadonlyArray<T> {
" __sortedArrayBrand": any;
}
export interface TypingInstallerRequestWithProjectName {
readonly projectName: string;
}
/* @internal */
export type TypingInstallerRequestUnion = DiscoverTypings | CloseProject | TypesRegistryRequest | InstallPackageRequest;
export interface DiscoverTypings extends TypingInstallerRequestWithProjectName {
readonly fileNames: string[];
readonly projectRootPath: Path;
readonly compilerOptions: CompilerOptions;
readonly typeAcquisition: TypeAcquisition;
readonly unresolvedImports: SortedReadonlyArray<string>;
readonly cachePath?: string;
readonly kind: "discover";
}
export interface CloseProject extends TypingInstallerRequestWithProjectName {
readonly kind: "closeProject";
}
export interface TypesRegistryRequest {
readonly kind: "typesRegistry";
}
export interface InstallPackageRequest extends TypingInstallerRequestWithProjectName {
readonly kind: "installPackage";
readonly fileName: Path;
readonly packageName: string;
readonly projectRootPath: Path;
}
export type ActionSet = "action::set";
export type ActionInvalidate = "action::invalidate";
export type ActionPackageInstalled = "action::packageInstalled";
export type EventTypesRegistry = "event::typesRegistry";
export type EventBeginInstallTypes = "event::beginInstallTypes";
export type EventEndInstallTypes = "event::endInstallTypes";
export type EventInitializationFailed = "event::initializationFailed";
export interface TypingInstallerResponse {
readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed;
}
/* @internal */
export type TypingInstallerResponseUnion = SetTypings | InvalidateCachedTypings | TypesRegistryResponse | PackageInstalledResponse | InstallTypes | InitializationFailedResponse;
/* @internal */
export interface TypesRegistryResponse extends TypingInstallerResponse {
readonly kind: EventTypesRegistry;
readonly typesRegistry: MapLike<MapLike<string>>;
}
export interface PackageInstalledResponse extends ProjectResponse {
readonly kind: ActionPackageInstalled;
readonly success: boolean;
readonly message: string;
}
export interface InitializationFailedResponse extends TypingInstallerResponse {
readonly kind: EventInitializationFailed;
readonly message: string;
}
export interface ProjectResponse extends TypingInstallerResponse {
readonly projectName: string;
}
export interface SetTypings extends ProjectResponse {
readonly typeAcquisition: TypeAcquisition;
readonly compilerOptions: CompilerOptions;
readonly typings: string[];
readonly unresolvedImports: SortedReadonlyArray<string>;
readonly kind: ActionSet;
}
export interface InvalidateCachedTypings extends ProjectResponse {
readonly kind: ActionInvalidate;
}
export interface InstallTypes extends ProjectResponse {
readonly kind: EventBeginInstallTypes | EventEndInstallTypes;
readonly eventId: number;
readonly typingsInstallerVersion: string;
readonly packagesToInstall: ReadonlyArray<string>;
}
export interface BeginInstallTypes extends InstallTypes {
readonly kind: EventBeginInstallTypes;
}
export interface EndInstallTypes extends InstallTypes {
readonly kind: EventEndInstallTypes;
readonly installSuccess: boolean;
}
/* @internal */
export interface InstallTypingHost extends JsTyping.TypingResolutionHost {
useCaseSensitiveFileNames: boolean;
writeFile(path: string, content: string): void;
createDirectory(path: string): void;
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
}
}

View File

@@ -1,12 +1,13 @@
{
"extends": "../tsconfig-base",
"compilerOptions": {
"outFile": "../../built/local/typescriptServices.js"
"outFile": "../../built/local/services.js"
},
"references": [
{ "path": "../core" },
{ "path": "../parser" },
{ "path": "../compiler" }
{ "path": "../compiler" },
{ "path": "../jsTyping" },
],
"files": [
"types.ts",
@@ -21,8 +22,6 @@
"getEditsForFileRename.ts",
"goToDefinition.ts",
"jsDoc.ts",
"semver.ts",
"jsTyping.ts",
"navigateTo.ts",
"navigationBar.ts",
"organizeImports.ts",

View File

@@ -4,6 +4,7 @@
"outFile": "../../built/local/run.js",
"composite": false,
"declaration": false,
"declarationMap": false,
"types": [
"node", "mocha", "chai"
],
@@ -17,10 +18,10 @@
{ "path": "../parser", "prepend": true },
{ "path": "../compiler", "prepend": true },
{ "path": "../services", "prepend": true },
{ "path": "../jsTyping", "prepend": true },
{ "path": "../server", "prepend": true },
{ "path": "../harness", "prepend": true },
{ "path": "../unittests", "prepend": true },
{ "path": "../typingsInstallerCore", "prepend": true }
{ "path": "../typingsInstallerCore", "prepend": true },
{ "path": "../harness", "prepend": true }
],
"files": [
@@ -35,6 +36,59 @@
"parallel/worker.ts",
"parallel/shared.ts",
"runner.ts"
"runner.ts",
"unittests/extractTestHelpers.ts",
"unittests/tsserverProjectSystem.ts",
"unittests/typingsInstaller.ts",
"unittests/asserts.ts",
"unittests/base64.ts",
"unittests/builder.ts",
"unittests/cancellableLanguageServiceOperations.ts",
"unittests/commandLineParsing.ts",
"unittests/compileOnSave.ts",
"unittests/configurationExtension.ts",
"unittests/convertCompilerOptionsFromJson.ts",
"unittests/convertToBase64.ts",
"unittests/convertTypeAcquisitionFromJson.ts",
"unittests/customTransforms.ts",
"unittests/extractConstants.ts",
"unittests/extractFunctions.ts",
"unittests/extractRanges.ts",
"unittests/hostNewLineSupport.ts",
"unittests/incrementalParser.ts",
"unittests/initializeTSConfig.ts",
"unittests/jsDocParsing.ts",
"unittests/languageService.ts",
"unittests/matchFiles.ts",
"unittests/moduleResolution.ts",
"unittests/organizeImports.ts",
"unittests/paths.ts",
"unittests/printer.ts",
"unittests/programMissingFiles.ts",
"unittests/programNoParseFalsyFileNames.ts",
"unittests/projectErrors.ts",
"unittests/projectReferences.ts",
"unittests/publicApi.ts",
"unittests/reuseProgramStructure.ts",
"unittests/session.ts",
"unittests/symbolWalker.ts",
"unittests/telemetry.ts",
"unittests/textChanges.ts",
"unittests/textStorage.ts",
"unittests/transform.ts",
"unittests/transpile.ts",
"unittests/tsbuild.ts",
"unittests/tsconfigParsing.ts",
"unittests/tscWatchMode.ts",
"unittests/versionCache.ts",
"unittests/evaluation/asyncArrow.ts",
"unittests/evaluation/asyncGenerator.ts",
"unittests/evaluation/forAwaitOf.ts",
"unittests/services/colorization.ts",
"unittests/services/documentRegistry.ts",
"unittests/services/patternMatcher.ts",
"unittests/services/preProcessFile.ts"
]
}

View File

@@ -197,7 +197,7 @@ and grew 1cm per day`;
before(() => {
// Use scanner.ts, decent size, does not change frequently
const testFileName = "src/compiler/scanner.ts";
const testFileName = "src/parser/scanner.ts";
testContent = Harness.IO.readFile(testFileName)!;
const totalChars = testContent.length;
assert.isTrue(totalChars > 0, "Failed to read test file.");

View File

@@ -5,6 +5,7 @@
"target": "es5",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"composite": true,
"noEmitOnError": true,

View File

@@ -15,6 +15,7 @@
{ "path": "../parser", "prepend": true },
{ "path": "../compiler", "prepend": true },
{ "path": "../services", "prepend": true },
{ "path": "../jsTyping", "prepend": true },
{ "path": "../server", "prepend": true }
]
}

View File

@@ -2,7 +2,7 @@
"extends": "../tsconfig-base",
"compilerOptions": {
"outFile": "../../built/local/tsserverGlobalLibrary.js",
"outFile": "../../built/local/tsserverlibrary.js",
"types": [
"node"
]
@@ -13,6 +13,7 @@
{ "path": "../parser", "prepend": true },
{ "path": "../compiler", "prepend": true },
{ "path": "../services", "prepend": true },
{ "path": "../jsTyping", "prepend": true },
{ "path": "../server", "prepend": true }
]
}

View File

@@ -0,0 +1 @@
// Delete soon

View File

@@ -0,0 +1,20 @@
{
"extends": "../tsconfig-base",
"compilerOptions": {
"outFile": "../../built/local/typescriptServices.js",
"types": [
"node"
]
},
"files": [
"empty.ts"
],
"references": [
{ "path": "../core", "prepend": true },
{ "path": "../parser", "prepend": true },
{ "path": "../compiler", "prepend": true },
{ "path": "../jsTyping", "prepend": true },
{ "path": "../services", "prepend": true },
]
}

View File

@@ -14,12 +14,7 @@
"references": [
{ "path": "../core", "prepend": true },
{ "path": "../parser", "prepend": true },
/* todo - only need jsTyping and semver from this compilation! */
{ "path": "../compiler", "prepend": true },
{ "path": "../services", "prepend": true },
{ "path": "../server", "prepend": true },
{ "path": "../jsTyping", "prepend": true },
{ "path": "../typingsInstallerCore", "prepend": true }
],
"files": [

View File

@@ -13,11 +13,7 @@
"references": [
{ "path": "../core" },
{ "path": "../parser" },
/* todo - only need jsTyping and semver from this compilation! */
{ "path": "../compiler" },
{ "path": "../services" },
{ "path": "../server" }
{ "path": "../jsTyping" }
],
"files": [
"typingsInstaller.ts"

View File

@@ -1,23 +0,0 @@
{
"extends": "../tsconfig-base",
"compilerOptions": {
"outFile": "../../built/local/unittests.js",
"types": [
"node", "mocha", "chai"
],
"lib": [
"es6",
"scripthost"
]
},
"references": [
{ "path": "../core" },
{ "path": "../parser" },
{ "path": "../compiler" },
{ "path": "../services" },
{ "path": "../server" },
{ "path": "../typingsInstallerCore" },
{ "path": "../harness" }
],
"include": ["*.ts", "**/*.ts"]
}