Produce tsc typings for "flipper" package
Summary: This diffs refactors tsc projects structure and structure of our custom typings to allow producing typescript typings for "flipper" package. In next diffs I'm going to use the produced typings to check compatibility of plugins with certain versions of Flipper, e.g. to check whether plugin is compatible with current "stable" and "insiders" version. Reviewed By: passy Differential Revision: D26997158 fbshipit-source-id: a0416c7139bf08ec9d175730da4c4c2a8768eeb7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
779e89db1d
commit
f468f0e07d
47
desktop/scripts/gen-type-index.ts
Normal file
47
desktop/scripts/gen-type-index.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {rootDir} from './paths';
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
async function genTypeIndex() {
|
||||
const typesDir = path.join(rootDir, 'types');
|
||||
const filePaths = (await fs.readdir(typesDir))
|
||||
.filter(
|
||||
(filePath) => filePath.endsWith('.d.ts') && filePath !== 'index.d.ts',
|
||||
)
|
||||
.sort();
|
||||
await fs.writeFile(
|
||||
path.join(typesDir, 'index.d.ts'),
|
||||
// @lint-ignore-every LICENSELINT
|
||||
`/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
${filePaths
|
||||
.map((filePath) => `/// <reference path="${filePath}" />`)
|
||||
.join('\n')}
|
||||
`,
|
||||
);
|
||||
}
|
||||
|
||||
genTypeIndex()
|
||||
.then(() => {
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((err: any) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user