fix type casts
This commit is contained in:
parent
f4ab083c28
commit
fc4b40b633
9 changed files with 19 additions and 19 deletions
|
@ -38,8 +38,8 @@ function getTypeScriptCompilerOptions(src: string): ts.CompilerOptions {
|
|||
}
|
||||
|
||||
function createCompile(src: string, build: boolean, emitError?: boolean) {
|
||||
const tsb = <typeof import('gulp-tsb')>require('gulp-tsb');
|
||||
const sourcemaps = <typeof import('gulp-sourcemaps')>require('gulp-sourcemaps');
|
||||
const tsb = require('gulp-tsb') as typeof import('gulp-tsb');
|
||||
const sourcemaps = require('gulp-sourcemaps') as typeof import('gulp-sourcemaps');
|
||||
|
||||
|
||||
const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json');
|
||||
|
@ -48,7 +48,7 @@ function createCompile(src: string, build: boolean, emitError?: boolean) {
|
|||
const compilation = tsb.create(projectPath, overrideOptions, false, err => reporter(err));
|
||||
|
||||
function pipeline(token?: util.ICancellationToken) {
|
||||
const bom = <typeof import('gulp-bom')>require('gulp-bom');
|
||||
const bom = require('gulp-bom') as typeof import('gulp-bom');
|
||||
|
||||
const utf8Filter = util.filter(data => /(\/|\\)test(\/|\\).*utf8/.test(data.path));
|
||||
const tsFilter = util.filter(data => /\.ts$/.test(data.path));
|
||||
|
|
|
@ -84,7 +84,7 @@ export const config = {
|
|||
function getElectron(arch: string): () => NodeJS.ReadWriteStream {
|
||||
return () => {
|
||||
const electron = require('gulp-atom-electron');
|
||||
const json = <typeof import('gulp-json-editor')>require('gulp-json-editor');
|
||||
const json = require('gulp-json-editor') as typeof import('gulp-json-editor');
|
||||
|
||||
const electronOpts = _.extend({}, config, {
|
||||
platform: process.platform,
|
||||
|
|
|
@ -92,7 +92,7 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string):
|
|||
}
|
||||
}
|
||||
|
||||
const vsce = <typeof import('vsce')>require('vsce');
|
||||
const vsce = require('vsce') as typeof import('vsce');
|
||||
const webpack = require('webpack');
|
||||
const webpackGulp = require('webpack-stream');
|
||||
|
||||
|
@ -174,7 +174,7 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string):
|
|||
function fromLocalNormal(extensionPath: string): Stream {
|
||||
const result = es.through();
|
||||
|
||||
const vsce = <typeof import('vsce')>require('vsce');
|
||||
const vsce = require('vsce') as typeof import('vsce');
|
||||
|
||||
vsce.listFiles({ cwd: extensionPath, packageManager: vsce.PackageManager.Yarn })
|
||||
.then(fileNames => {
|
||||
|
@ -202,7 +202,7 @@ const baseHeaders = {
|
|||
|
||||
export function fromMarketplace(extensionName: string, version: string, metadata: any): Stream {
|
||||
const remote = require('gulp-remote-retry-src');
|
||||
const json = <typeof import('gulp-json-editor')>require('gulp-json-editor');
|
||||
const json = require('gulp-json-editor') as typeof import('gulp-json-editor');
|
||||
|
||||
const [publisher, name] = extensionName.split('.');
|
||||
const url = `https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${publisher}/vsextensions/${name}/${version}/vspackage`;
|
||||
|
|
|
@ -621,7 +621,7 @@ export class DeclarationResolver {
|
|||
private _sourceFileCache: { [moduleId: string]: CacheEntry | null; };
|
||||
|
||||
constructor(private readonly _fsProvider: FSProvider) {
|
||||
this.ts = <typeof import('typescript')>require('typescript');
|
||||
this.ts = require('typescript') as typeof import('typescript');
|
||||
this._sourceFileCache = Object.create(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -438,7 +438,7 @@ module _nls {
|
|||
}
|
||||
|
||||
export function patchFiles(javascriptFile: File, typescript: string): File[] {
|
||||
const ts = <typeof import('typescript')>require('typescript');
|
||||
const ts = require('typescript') as typeof import('typescript');
|
||||
// hack?
|
||||
const moduleId = javascriptFile.relative
|
||||
.replace(/\.js$/, '')
|
||||
|
|
|
@ -179,7 +179,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
|
|||
const fileContentMapper = opts.fileContentMapper || ((contents: string, _path: string) => contents);
|
||||
|
||||
return function () {
|
||||
const sourcemaps = <typeof import('gulp-sourcemaps')>require('gulp-sourcemaps');
|
||||
const sourcemaps = require('gulp-sourcemaps') as typeof import('gulp-sourcemaps');
|
||||
|
||||
const bundlesStream = es.through(); // this stream will contain the bundled files
|
||||
const resourcesStream = es.through(); // this stream will contain the resources
|
||||
|
@ -240,8 +240,8 @@ declare class FileWithCopyright extends VinylFile {
|
|||
* to have a file "context" to include our copyright only once per file.
|
||||
*/
|
||||
function uglifyWithCopyrights(): NodeJS.ReadWriteStream {
|
||||
const composer = <typeof import('gulp-uglify/composer')>require('gulp-uglify/composer');
|
||||
const terser = <typeof import('terser')>require('terser');
|
||||
const composer = require('gulp-uglify/composer') as typeof import('gulp-uglify/composer');
|
||||
const terser = require('terser') as typeof import('terser');
|
||||
|
||||
const preserveComments = (f: FileWithCopyright) => {
|
||||
return (_node: any, comment: { value: string; type: string; }) => {
|
||||
|
@ -291,9 +291,9 @@ export function minifyTask(src: string, sourceMapBaseUrl?: string): (cb: any) =>
|
|||
const sourceMappingURL = sourceMapBaseUrl ? ((f: any) => `${sourceMapBaseUrl}/${f.relative}.map`) : undefined;
|
||||
|
||||
return cb => {
|
||||
const minifyCSS = <typeof import('gulp-cssnano')>require('gulp-cssnano');
|
||||
const uglify = <typeof import('gulp-uglify')>require('gulp-uglify');
|
||||
const sourcemaps = <typeof import('gulp-sourcemaps')>require('gulp-sourcemaps');
|
||||
const minifyCSS = require('gulp-cssnano') as typeof import('gulp-cssnano');
|
||||
const uglify = require('gulp-uglify') as typeof import('gulp-uglify');
|
||||
const sourcemaps = require('gulp-sourcemaps') as typeof import('gulp-sourcemaps');
|
||||
|
||||
const jsFilter = filter('**/*.js', { restore: true });
|
||||
const cssFilter = filter('**/*.css', { restore: true });
|
||||
|
|
|
@ -30,7 +30,7 @@ function writeFile(filePath: string, contents: Buffer | string): void {
|
|||
}
|
||||
|
||||
export function extractEditor(options: tss.ITreeShakingOptions & { destRoot: string }): void {
|
||||
const ts = <typeof import('typescript')>require('typescript');
|
||||
const ts = require('typescript') as typeof import('typescript');
|
||||
|
||||
const tsConfig = JSON.parse(fs.readFileSync(path.join(options.sourcesRoot, 'tsconfig.monaco.json')).toString());
|
||||
let compilerOptions: { [key: string]: any };
|
||||
|
@ -135,7 +135,7 @@ export interface IOptions2 {
|
|||
}
|
||||
|
||||
export function createESMSourcesAndResources2(options: IOptions2): void {
|
||||
const ts = <typeof import('typescript')>require('typescript');
|
||||
const ts = require('typescript') as typeof import('typescript');
|
||||
|
||||
const SRC_FOLDER = path.join(REPO_ROOT, options.srcFolder);
|
||||
const OUT_FOLDER = path.join(REPO_ROOT, options.outFolder);
|
||||
|
|
|
@ -74,7 +74,7 @@ export function createStatsStream(group: string, log?: boolean): es.ThroughStrea
|
|||
}
|
||||
|
||||
export function submitAllStats(productJson: any, commit: string): Promise<boolean> {
|
||||
const appInsights = <typeof import('applicationinsights')>require('applicationinsights');
|
||||
const appInsights = require('applicationinsights') as typeof import('applicationinsights');
|
||||
|
||||
const sorted: Entry[] = [];
|
||||
// move entries for single files to the front
|
||||
|
|
|
@ -82,7 +82,7 @@ function printDiagnostics(options: ITreeShakingOptions, diagnostics: ReadonlyArr
|
|||
}
|
||||
|
||||
export function shake(options: ITreeShakingOptions): ITreeShakingResult {
|
||||
const ts = <typeof import('typescript')>require('typescript');
|
||||
const ts = require('typescript') as typeof import('typescript');
|
||||
const languageService = createTypeScriptLanguageService(ts, options);
|
||||
const program = languageService.getProgram()!;
|
||||
|
||||
|
|
Loading…
Reference in a new issue