Skip to content
Permalink
Browse files
Use typescript.d.ts in APISample tests (#51061)
  • Loading branch information
jakebailey committed Oct 4, 2022
1 parent 4953316 commit 8af9a936b5240398370887c22cacaff65fee707b
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 71 deletions.
@@ -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,
@@ -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]
@@ -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]
@@ -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]
@@ -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]
@@ -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]
@@ -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]
@@ -68,7 +69,8 @@ fileNames.forEach(fileName => {

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


//// [APISample_linter.js]
"use strict";
@@ -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]
@@ -40,7 +41,8 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string):
return undefined;
}
return ts.createProgram(rootFiles, settings.options);
}
}


//// [APISample_parseConfig.js]
"use strict";
@@ -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]
@@ -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";
@@ -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]
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -72,4 +72,4 @@ fileNames.forEach(fileName => {

// delint it
delint(sourceFile);
});
});
@@ -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
@@ -44,4 +44,4 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string):
return undefined;
}
return ts.createProgram(rootFiles, settings.options);
}
}
@@ -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
@@ -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));
@@ -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

0 comments on commit 8af9a93

Please sign in to comment.