Skip to content

Commit

Permalink
Use typescript.d.ts in APISample tests (#51061)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Oct 4, 2022
1 parent 4953316 commit 8af9a93
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 71 deletions.
2 changes: 0 additions & 2 deletions src/harness/harnessIO.ts
Expand Up @@ -177,8 +177,6 @@ namespace Harness {
}

export const libFolder = "built/local/";
const tcServicesFileName = ts.combinePaths(libFolder, "typescriptServices.js");
export const tcServicesFile = IO.readFile(tcServicesFileName) + IO.newLine() + `//# sourceURL=${IO.resolvePath(tcServicesFileName)}`;

export type SourceMapEmitterCallback = (
emittedFile: string,
Expand Down
7 changes: 4 additions & 3 deletions tests/baselines/reference/APISample_Watch.js
@@ -1,8 +1,9 @@
//// [tests/cases/compiler/APISample_Watch.ts] ////

//// [index.d.ts]
declare module "typescript" {
export = ts;
//// [package.json]
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

//// [APISample_Watch.ts]
Expand Down
7 changes: 4 additions & 3 deletions tests/baselines/reference/APISample_WatchWithDefaults.js
@@ -1,8 +1,9 @@
//// [tests/cases/compiler/APISample_WatchWithDefaults.ts] ////

//// [index.d.ts]
declare module "typescript" {
export = ts;
//// [package.json]
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

//// [APISample_WatchWithDefaults.ts]
Expand Down
7 changes: 4 additions & 3 deletions tests/baselines/reference/APISample_WatchWithOwnWatchHost.js
@@ -1,8 +1,9 @@
//// [tests/cases/compiler/APISample_WatchWithOwnWatchHost.ts] ////

//// [index.d.ts]
declare module "typescript" {
export = ts;
//// [package.json]
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

//// [APISample_WatchWithOwnWatchHost.ts]
Expand Down
7 changes: 4 additions & 3 deletions tests/baselines/reference/APISample_compile.js
@@ -1,8 +1,9 @@
//// [tests/cases/compiler/APISample_compile.ts] ////

//// [index.d.ts]
declare module "typescript" {
export = ts;
//// [package.json]
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

//// [APISample_compile.ts]
Expand Down
7 changes: 4 additions & 3 deletions tests/baselines/reference/APISample_jsdoc.js
@@ -1,8 +1,9 @@
//// [tests/cases/compiler/APISample_jsdoc.ts] ////

//// [index.d.ts]
declare module "typescript" {
export = ts;
//// [package.json]
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

//// [APISample_jsdoc.ts]
Expand Down
10 changes: 6 additions & 4 deletions tests/baselines/reference/APISample_linter.js
@@ -1,8 +1,9 @@
//// [tests/cases/compiler/APISample_linter.ts] ////

//// [index.d.ts]
declare module "typescript" {
export = ts;
//// [package.json]
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

//// [APISample_linter.ts]
Expand Down Expand Up @@ -68,7 +69,8 @@ fileNames.forEach(fileName => {

// delint it
delint(sourceFile);
});
});


//// [APISample_linter.js]
"use strict";
Expand Down
10 changes: 6 additions & 4 deletions tests/baselines/reference/APISample_parseConfig.js
@@ -1,8 +1,9 @@
//// [tests/cases/compiler/APISample_parseConfig.ts] ////

//// [index.d.ts]
declare module "typescript" {
export = ts;
//// [package.json]
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

//// [APISample_parseConfig.ts]
Expand Down Expand Up @@ -40,7 +41,8 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string):
return undefined;
}
return ts.createProgram(rootFiles, settings.options);
}
}


//// [APISample_parseConfig.js]
"use strict";
Expand Down
10 changes: 6 additions & 4 deletions tests/baselines/reference/APISample_transform.js
@@ -1,8 +1,9 @@
//// [tests/cases/compiler/APISample_transform.ts] ////

//// [index.d.ts]
declare module "typescript" {
export = ts;
//// [package.json]
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

//// [APISample_transform.ts]
Expand All @@ -20,7 +21,8 @@ const source = "let x: string = 'string'";

let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });

console.log(JSON.stringify(result));
console.log(JSON.stringify(result));


//// [APISample_transform.js]
"use strict";
Expand Down
7 changes: 4 additions & 3 deletions tests/baselines/reference/APISample_watcher.js
@@ -1,8 +1,9 @@
//// [tests/cases/compiler/APISample_watcher.ts] ////

//// [index.d.ts]
declare module "typescript" {
export = ts;
//// [package.json]
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

//// [APISample_watcher.ts]
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/compiler/APISample_Watch.ts
@@ -1,12 +1,12 @@
// @module: commonjs
// @skipLibCheck: true
// @includebuiltfile: typescriptServices.d.ts
// @noImplicitAny:true
// @strictNullChecks:true

// @filename: node_modules/typescript/index.d.ts
declare module "typescript" {
export = ts;
// @filename: node_modules/typescript/package.json
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

// @filename: APISample_Watch.ts
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/compiler/APISample_WatchWithDefaults.ts
@@ -1,12 +1,12 @@
// @module: commonjs
// @skipLibCheck: true
// @includebuiltfile: typescriptServices.d.ts
// @noImplicitAny:true
// @strictNullChecks:true

// @filename: node_modules/typescript/index.d.ts
declare module "typescript" {
export = ts;
// @filename: node_modules/typescript/package.json
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

// @filename: APISample_WatchWithDefaults.ts
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/compiler/APISample_WatchWithOwnWatchHost.ts
@@ -1,12 +1,12 @@
// @module: commonjs
// @skipLibCheck: true
// @includebuiltfile: typescriptServices.d.ts
// @noImplicitAny:true
// @strictNullChecks:true

// @filename: node_modules/typescript/index.d.ts
declare module "typescript" {
export = ts;
// @filename: node_modules/typescript/package.json
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

// @filename: APISample_WatchWithOwnWatchHost.ts
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/compiler/APISample_compile.ts
@@ -1,12 +1,12 @@
// @module: commonjs
// @skipLibCheck: true
// @includebuiltfile: typescriptServices.d.ts
// @noImplicitAny:true
// @strictNullChecks:true

// @filename: node_modules/typescript/index.d.ts
declare module "typescript" {
export = ts;
// @filename: node_modules/typescript/package.json
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

// @filename: APISample_compile.ts
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/compiler/APISample_jsdoc.ts
@@ -1,12 +1,12 @@
// @module: commonjs
// @skipLibCheck: true
// @includebuiltfile: typescriptServices.d.ts
// @noImplicitAny:true
// @strictNullChecks:true

// @filename: node_modules/typescript/index.d.ts
declare module "typescript" {
export = ts;
// @filename: node_modules/typescript/package.json
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

// @filename: APISample_jsdoc.ts
Expand Down
10 changes: 5 additions & 5 deletions tests/cases/compiler/APISample_linter.ts
@@ -1,12 +1,12 @@
// @module: commonjs
// @skipLibCheck: true
// @includebuiltfile: typescriptServices.d.ts
// @noImplicitAny:true
// @strictNullChecks:true

// @filename: node_modules/typescript/index.d.ts
declare module "typescript" {
export = ts;
// @filename: node_modules/typescript/package.json
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

// @filename: APISample_linter.ts
Expand Down Expand Up @@ -72,4 +72,4 @@ fileNames.forEach(fileName => {

// delint it
delint(sourceFile);
});
});
10 changes: 5 additions & 5 deletions tests/cases/compiler/APISample_parseConfig.ts
@@ -1,12 +1,12 @@
// @module: commonjs
// @skipLibCheck: true
// @includebuiltfile: typescriptServices.d.ts
// @noImplicitAny:true
// @strictNullChecks:true

// @filename: node_modules/typescript/index.d.ts
declare module "typescript" {
export = ts;
// @filename: node_modules/typescript/package.json
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

// @filename: APISample_parseConfig.ts
Expand Down Expand Up @@ -44,4 +44,4 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string):
return undefined;
}
return ts.createProgram(rootFiles, settings.options);
}
}
10 changes: 5 additions & 5 deletions tests/cases/compiler/APISample_transform.ts
@@ -1,12 +1,12 @@
// @module: commonjs
// @skipLibCheck: true
// @includebuiltfile: typescriptServices.d.ts
// @noImplicitAny:true
// @strictNullChecks:true

// @filename: node_modules/typescript/index.d.ts
declare module "typescript" {
export = ts;
// @filename: node_modules/typescript/package.json
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

// @filename: APISample_transform.ts
Expand All @@ -24,4 +24,4 @@ const source = "let x: string = 'string'";

let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });

console.log(JSON.stringify(result));
console.log(JSON.stringify(result));
8 changes: 4 additions & 4 deletions tests/cases/compiler/APISample_watcher.ts
@@ -1,12 +1,12 @@
// @module: commonjs
// @skipLibCheck: true
// @includebuiltfile: typescriptServices.d.ts
// @noImplicitAny:true
// @strictNullChecks:true

// @filename: node_modules/typescript/index.d.ts
declare module "typescript" {
export = ts;
// @filename: node_modules/typescript/package.json
{
"name": "typescript",
"types": "/.ts/typescript.d.ts"
}

// @filename: APISample_watcher.ts
Expand Down

0 comments on commit 8af9a93

Please sign in to comment.