У меня есть один случай, который я никогда раньше не видел, обычно, когда я создаю интерфейс машинописного текста, я его экспортирую, чтобы импортировать в другой файл, но сейчас у меня есть случай, когда мой другой файл распознает интерфейс, даже если он не импортируется специально IBuffer
import {
IObjectStorageClient,
IUploadObjectResult,
IDeleteObjectResult,
IDeleteObjectOptions,
IDownloadObjectOptions,
IDownloadObjectResult
} from "personnalLib"
import * as _request from 'superagent';
import { IInfraStorageConfig } from "../../config/configs";
class StorageService implements IStorageService{
public infraStorageConf : IInfraStorageConfig;
public client: IObjectStorageClient;
public async saveBuffers(bufferToSave:IBuffer):Promise<any> {
// bufferTosave.infraKeyValue =bufferTosave.infraKeyValue ? bufferTosave.infraKeyValue : [] as any
const access_token= (await this.generateStorageToken()).access_token;
try{
const storageResponse = await this.client.uploadObject({
data: Buffer.from(bufferToSave.data!),
contentType: bufferToSave!.contentType!,
objectName: bufferToSave.fileName!,
ttl: bufferToSave.ttl?bufferToSave.ttl:0, // ~1 year
accessToken:access_token
}).catch((err: any) =>{
throw err
})
return {
key:storageResponse.objectId,
value:storageResponse.metadata
};
}catch(err){
throw err
}
}
Так вот мой вопрос? Это новая функция? потому что некоторые из моих коллег не могут скомпилировать этот вид кода, и я могу, я имею в типе 2.9.2 в рабочей области, и VSCode находится в 3.7,
вот мой вариант компилятора:
"compilerOptions": {
"declaration": true,
"module": "commonjs",
"noImplicitAny": true,
"sourceMap": true,
"pretty": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"outDir": "dist/",
}
и они расширяют опции этого компилятора из библиотеки lib:
{
"extends": "./tsconfig-required.json",
"compilerOptions": {
"target": "es2017",
"lib": [
"es2017"
],
"module": "commonjs",
"newLine": "LF",
"charset": "utf8",
"suppressImplicitAnyIndexErrors": true,
"alwaysStrict": true,
"plugins": [{
"name": "tslint-language-service"
}]
},
"exclude": ["dist", "temp", "node_modules", "output", "log", "test-data", "generated", ".*"]
}
здесь требуется ts-config. json
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}